homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Escaping characters in JS

 10:51 pm on May 7, 2003 (gmt 0)

Can't seem to get this to work as a JS include. I'm missing the escape somewhere because it works as HTML:
* line break added to prevent side-scroll

document.writeln('<a href="#"
*\'scrollbars=no,menubar=no,status=no,resize=no,toolbar=0,top=60,left=60,width=582,height=356\'); return false;" target="radio"><img src="images2/webcasts.gif" border="0" width="82" height="22" vspace="15" align="middle" alt="Jazz Webcasts"><\/a>');

[edited by: tedster at 11:16 pm (utc) on May 7, 2003]
[edit reason] prevent side scroll/use generic URL [/edit]



 2:06 am on May 8, 2003 (gmt 0)



 2:48 am on May 8, 2003 (gmt 0)

I haven't tried this, but you might have to also escape the double quotes.

Perhaps create a variable with the URL and just use that it in your window.open instead of trying to use the actual information and having to escape the quotes.


 2:52 am on May 8, 2003 (gmt 0)

It's late and I'm not that great with JS. But I pasted your code (minus the line break stuff) into a file in my web root called /js.inc and included it in an HTML file. It didn't throw any errors in IE 6.0. That makes me wonder if there's a bug in your HTML include tag? I used <script type="text/javascript" src="/js.inc"></script>.


 3:12 am on May 8, 2003 (gmt 0)

No, no bug in my HTML, and escaping the double quotes does not fix it either. Never had to escape double quotes before, but just for the heck of it I tried it. I have pretty much tried everything I can guess at.


 4:27 am on May 8, 2003 (gmt 0)

keyplyr, if that code you posted was a copy/paste, look at the word writeln -- it should be writeIn, but there's a lower case "L" instead of an upper case "I"


 6:17 am on May 8, 2003 (gmt 0)

...it should be writeIn - Tedster


writeln stands for "write line", not "write in" - but thanks for trying to help, I ceratinly need it.


 6:48 am on May 8, 2003 (gmt 0)

Sucess! And it only took 12 hours.

Needed to use 2 writeln commands because the internal JS needed to all be written on one line to avoid the unterminated string constant error which was prohibiting the entire script from even displaying.

Thanks to all who helped me muddle through the possibilities.


 7:35 am on May 8, 2003 (gmt 0)

> writeln stands for "write line", not "write in"

Wow, do I feel like an idiot. I've never used writeln, but I "thought" I knew about it. Thanks for teaching me a thing or two - I've been misreading that one for years.


 9:51 am on May 8, 2003 (gmt 0)

Good catch!

It's important to remember that document.write and document.writeln both need to be on one line. If there is a line break the script will fail.


 11:33 pm on May 8, 2003 (gmt 0)

document.write and document.writeln both need to be on one line

Which is downright an oddity. In java, you can have the line breaks anywhere you like until the compiler sees the semi-colon. In javascript, you'd think the same syntax would carry through, but it doesn't. A CR/LF is treated like it were VB rather than a pseudo-java language.


 3:55 am on May 9, 2003 (gmt 0)

Just a note. You can use line breaks if the line ends in +

document.write('1' +
'<br>' +

Alerts act the same way.

alert('1' +
'\n' +

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved