Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jun 2002
    Posts
    70
    Thanks
    0
    Thanked 0 Times in 0 Posts

    document.write('\/')

    Hi. Here's the situation. I have a asp script. It does:

    x = '<a href="http:\/\/tmp.htm">title<\/a>'
    Response.Write("a[0] = '"+x+"'")

    which generates this javascript code:

    a[0] = '<a href="http://tmp.htm">title</a>'

    At some point the javascript code will do a document.all('id').innerHTML = a[0].

    This works, but I'm confused. Isn't innerHTML just like write(), in that all '/' needs to be set to '\/'. Just when do you have to do this kind of parsing?

  • #2
    Senior Coder
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    1,063
    Thanks
    2
    Thanked 0 Times in 0 Posts
    when the / could mean something else.

    I use when I use a lot of quotes.

    say I want to alert "hello" (with the quotes) but it is onclick.

    Code:
    onclick=" /"hello/" "
    Shawn

  • #3
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Shouldn't that be the backslashes instead of forward slashes, shlagish?

    A backslash is used to escape special characters, such as quotes, forward slashes etc.

  • #4
    Senior Coder
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    1,063
    Thanks
    2
    Thanked 0 Times in 0 Posts
    whooooops

    yes yes, listen to Nightfire, he's got me outwised
    Shawn

  • #5
    New Coder
    Join Date
    Jun 2002
    Posts
    70
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I just want to find out when you need to convert '/' to '\/'...Dennis

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,033
    Thanks
    0
    Thanked 248 Times in 245 Posts
    when you are writing out strings that have closing tags especially the </script> tag.

    document.write('<script src="file.js"><\/script>');


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •