In line comment //@@ gives Invalid character

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • getmeidea
    New Member
    • Feb 2007
    • 36

    In line comment //@@ gives Invalid character

    I have the following function in my javascript file
    CODE:

    [CODE=javascript]function displayFullName (firstName, lastName) {
    if(lastName != null) { //@@ Appnds only when last name exists
    return (firstName + ' ' + lastName);
    } else {
    return firstName;
    }
    }
    [/CODE]
    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 16 '08, 07:41 AM. Reason: added code tags
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    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

    Comment

    • getmeidea
      New Member
      • Feb 2007
      • 36

      #3
      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.

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        hi ...

        i just tested it with IE6:

        [HTML]
        <script type="text/javascript">
        function displayFullName (firstName, lastName) {
        if(lastName != null) { //@@ Appnds only when last name exists
        return (firstName + ' ' + lastName);
        } else {
        return firstName;
        }
        }
        </script>
        <body onload="alert(d isplayFullName( 1,2));">
        </body>
        [/HTML]
        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

        Comment

        Working...