Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

converting an HTML file to js

Status
Not open for further replies.

fpl9250

Programmer
Jan 22, 2007
46
US
Hello,

I'm converting an html file into a .js by wrapping every line with

document.write('........');

but if it's a line of code that already has a single quote, then the whole line gets messed up.

Does anybody know how I can get around this issue?

Thank you.
 
You can either escape the single quote in the text by putting a \ (backslash) before it, or just use double quotes on the document.write statement.

document.write('this was Harry\'s Book titled');

document.write("this was Harry's Book titled");


[monkey][snake] <.
 
two questions :

1. Why are you moving an entire HTML file into JS ?
2. You may get better performance by building a JS String and then doing a single DOCUMENT.WRITE.

Greg Griffiths
Livelink Certified Developer & ECM Global Star Champion 2005 & 2006
 
ggriffit,

Your option sounds interesting. Can you please explain more? The content that I'm converting to js will wrap my look-and-feel around third-party content. The third party content people do not want to host or maintain my "wrapper" and thus they just want to reference it by calling a js. Your options sounds good looking into, but I need more info.

Thanks as well to the other two posts. That'll help a lot.
 
No it's more than that. It's the whole branding. Logo, menu, footer. The whole works. It will look like if you are in our site, but you are really not.

Do you have some info about that js string?

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top