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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    write method delete "past space" string

    Hello

    I'm quite new to JS, and I'm tring to write the document with document.write(),
    but if there a space in the string it eliminate all the text after the space.
    I tried this:
    Code:
    function _Start(){
    var _string = "My Dog";
    document.write(_string+"</br>");
    document.write("<a href=/"+'\"'+_string+'\"'+">Sample</a>");
    }
    Code:
    My Dog
    Sample {c:\..\"My}
    I know that the reason is that the string needs to be under "" for not to elminate the text, but I just can't figure it out how to ...

  • #2
    Senior Coder
    Join Date
    Oct 2008
    Location
    Long Beach
    Posts
    1,196
    Thanks
    36
    Thanked 164 Times in 164 Posts
    either of the following two options will work just fine, you were just escaping the wrong quotes:
    Code:
    document.write('<a href="'+_string+'">Sample</a>');
    document.write("<a href=\""+_string+"\">Sample</a>");
    Feel free to e-mail me if I forget to respond ;)
    ohsosexybrit@gmail.com


  •  

    Posting Permissions

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