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

problem with window.document.write("<script language=javascript>&quot 1

Status
Not open for further replies.

fernanss

Programmer
Oct 25, 2001
5
ES
I have got an html page which tries to write another page in a different window:


<html>
<body>
<script language=&quot;javascript&quot;>

var vent=eval(&quot;top.arbol.document&quot;);

function dibuja_arbol() {
vent.clear();
vent.writeln(&quot;<html><head>&quot;);


vent.writeln(&quot;<title>&quot;);
vent.writeln(&quot;alta de TCI&quot;);
vent.writeln(&quot;</title>&quot;);

vent.writeln(&quot;<script language='javascript'>&quot;);
vent.writeln(&quot;</script>&quot;);
vent.writeln(&quot;</head><body>&quot;);

.........................


vent.writeln(&quot;</body></html>&quot;);
vent.close();
}
dibuja_arbol();
</script>

</body>
</html>


The part: &quot;vent.writeln(&quot;<script language='javascript'>&quot;);
vent.writeln(&quot;</script>&quot;);&quot; is not translated correctly by the browser. It considers that the strings are not literals, but part of the main HTML page.
if I eliminate this part, everything goes ok. Any idea?
 
A cheaty way that might work:

Code:
vent.writeln( &quot;<&quot; + &quot;script language='javascript'&quot; + &quot;>&quot; );
vent.writeln( &quot;<&quot; + &quot;/script&quot; + &quot;>&quot; );

Cheers, Neil
 
I had a similar problem, though in a different context, and the way I solved it was to simply split the offending tags across two write statements, like this:
Code:
    vent.write(&quot;<scri&quot;);
    vent.writeln(&quot;pt language='javascript'>&quot;);
    vent.write(&quot;</scr&quot;);
    vent.writeln(&quot;ipt>&quot;);
NOTE that the statements that write the first part of the tag use write NOT writeln! You don't want a linefeed after the first half of the tag!

This trick is pretty much the same as toolkit's solution, but a little easier to code (IMHO). Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top