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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

document.write('<script'>)

Status
Not open for further replies.

MortHog

Programmer
Aug 24, 2002
3
GB
Interesting!
It appears that I cannot do document.write('<script language=Javascript src=blaa.js>'). In fact, I cannot do document.write('<script>') at all.
It writes it all to the source, but it doesn't show it on the document.

For instance..
document.write('moo<script><//script>woof')
If I view the source, I see: moo<script><//script>woof

However, on the page, I only see the moo.

Why is this??
 
You have to break up the close script tag like:

document.write('</scr' + 'ipt>');
 
Do this:
document.write('moo<script></script>woof')

When it sees &quot;//&quot; in the script tag, it doesn't finish the line because &quot;//&quot; is how to comment out a line. Besides, in html, it only needs </script>, not <//script>.

Rick if(($question==&quot;has been bugging me&quot;
AND $answer==&quot;fixed the problem&quot;) OR $answer==&quot;really good post&quot;){
print(&quot;Star&quot;);
}else{
print(&quot;Thanks.&quot;);
}
 
also you'll get a unterminating error in the string if you don't tell it to ignore the /
document.write('moo<script><\/script>woof') Hope that helps,
Ted
admin@onpntwebdesigns.com
 
example
<script>
document.write(&quot;moo!&quot;);
document.write(&quot;<script>&quot;);
document.write(&quot;alert\('hello!'\)&quot;);
document.write(&quot;<\/script>&quot;);
document.write(&quot;woof!&quot;);
</script> Hope that helps,
Ted
admin@onpntwebdesigns.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top