PDA

View Full Version : document.write() problems


philliptune
11-17-2005, 02:29 PM
So I'm trying to streamline development of a long list of pages by using JavaScript and variables. I'm just learning this stuff as I go along and I remembered seeing something called document.write() to write out html where the script is put. But as I'm writing the lines of the page, my other <script>s that I'm trying to write in are exiting my "big" script.

<script name="big">
document.write('<html>')
document.write(' <head>')
document.write(' <script src="../scripts/little.js" language="javascript" type="text/javascript"></script>')
</script>

See, the </script> on my "little" script is exiting my "big" script. How do I keep it from doing that?

Also, is there going to be any cross-browser compatability problems by using JavaScript or this "document.write" script?

RysChwith
11-17-2005, 04:27 PM
Try escaping the slashes: document.write(' <script src="..\/scripts\/little.js" language="javascript" type="text\/javascript"><\/script>')Rys

philliptune
11-17-2005, 04:53 PM
yeah, i figured it had something to do with escaping... just didn't know where to put it. Thanks, that worked great.