Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

In line comment //@@ gives Invalid character

Question posted by: getmeidea (Newbie) on May 16th, 2008 07:06 AM
I have the following function in my javascript file
CODE:

Code: ( text )
  1. function displayFullName(firstName, lastName) {
  2.   if(lastName != null) { //@@ Appnds only when last name exists
  3.     return (firstName + ' ' + lastName);
  4.   } else {
  5.     return firstName;
  6.   }
  7. }

Here the inline comment gives me error "Invalid character".
When I remove @@ it works fine for me.

What is the reason behind this ?
Last edited by gits : May 16th, 2008 at 07:41 AM. Reason: added code tags
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
gits's Avatar
gits
Moderator
3,047 Posts
May 16th, 2008
07:46 AM
#2

Re: In line comment //@@ gives Invalid character
i tested in firefox ... it works without an error ... with which browser does the error occur? is the script included in the page already or do you load it dynamically?

kind regards

Reply
getmeidea's Avatar
getmeidea
Newbie
31 Posts
May 16th, 2008
01:03 PM
#3

Re: In line comment //@@ gives Invalid character
Quote:
Originally Posted by gits
i tested in firefox ... it works without an error ... with which browser does the error occur? is the script included in the page already or do you load it dynamically?

kind regards


I am doing to work on IE 6.0.
First I tried with dynamically loading then I include initially itself. The error populates when the script inclusion happens.

Reply
gits's Avatar
gits
Moderator
3,047 Posts
May 16th, 2008
02:00 PM
#4

Re: In line comment //@@ gives Invalid character
hi ...

i just tested it with IE6:

Code: ( text )
  1. <script type="text/javascript">
  2. function displayFullName(firstName, lastName) {
  3.   if(lastName != null) { //@@ Appnds only when last name exists
  4.     return (firstName + ' ' + lastName);
  5.   } else {
  6.     return firstName;
  7.   }
  8. }
  9. </script>
  10. <body onload="alert(displayFullName(1,2));">
  11. </body>

worked without problems ... it might be a problem with another part of your code ... could you post a link to a testpage or test it yourself with firefox and have a look at the error-console to get a better error-description? the comment shouldn't make any problem ... in case it does and everything works ok!! when you remove it, then just remove it ... but i really think that there should be another problem ... as i said ... the code you currently posted is syntactically correct ...

kind regards

Reply
Reply
Not the answer you were looking for? Post your question . . .
178,103 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Top Javascript / DHTML / Ajax Forum Contributors