document.write with "li" in IE end tags disappear

  • Thread starter Oliver Gargour \(Garwin\)
  • Start date
O

Oliver Gargour \(Garwin\)

Hello, I'm tring to write "ul" and "li" tags to an iframe with IE8

window.attachEvent('onload',function(){Build();});

function Build() {
var Temp = eval("Test");
Temp.document.open();
Temp.document.write("<html>" +
"<head>" +
"</head>" +
"<body>" +
"<ul><li>blablabla</li><li>tratratra</li></ul>" +
"</body>" +
"</html>");
Temp.document.close();
alert("Temp="+Temp.document.body.innerHTML); }

<iframe id="Test" src="about:blank" style="PADDING-RIGHT: 0px; PADDING-LEFT:
0px; PADDING-BOTTOM: 0px; WIDTH: 598px; PADDING-TOP: 0px; HEIGHT:
349px"></iframe>

The problem is that some of the "li" closing tags disappear!!!!

The above alert gives :
Temp=<UL>
<LI>Internet
<LI>Creation</LI></UL>
 
L

Lasse Reichstein Nielsen

Oliver Gargour \(Garwin\) said:
function Build() {
var Temp = eval("Test");

Drop the eval, it does nothing here. You could just write
var Temp = Test;
I would recommend
var temp = document.frames['Test'];
instead, though.
Temp.document.open();
Temp.document.write("<html>" +
"<head>" +
"</head>" +
"<body>" +
"<ul><li>blablabla</li><li>tratratra</li></ul>" +
"</body>" +
"</html>");
Temp.document.close();
alert("Temp="+Temp.document.body.innerHTML); }

I take it this is not the actual code, and that the actual code is inside
the Build function.
<iframe id="Test" src="about:blank" style="PADDING-RIGHT: 0px; PADDING-LEFT:
0px; PADDING-BOTTOM: 0px; WIDTH: 598px; PADDING-TOP: 0px; HEIGHT:
349px"></iframe>

The problem is that some of the "li" closing tags disappear!!!!

The above alert gives :
Temp=<UL>
<LI>Internet
<LI>Creation</LI></UL>

The problem is your expectations :)
IE isn't following any standard with innerHTML, so there is no specified
way it must represent its document structure. Apparently it chooses to
omit the li end tag when building a string representation of the document.
The li end tag may be omitted in HTML, so that's perfectly reasonable.

Is there a problem with the display of the list?

/L
 
D

David Mark

Lasse said:
Oliver Gargour \(Garwin\) said:
function Build() {
var Temp = eval("Test");

Drop the eval, it does nothing here. You could just write
var Temp = Test;
I would recommend
var temp = document.frames['Test'];
instead, though.

Did you mean window.frames? I honestly don't know which is the
standard, but document.frames doesn't make much sense to me (and is
undefined in FF1).
 
D

David Mark

David said:
Lasse said:
Oliver Gargour \(Garwin\) said:
function Build() {
var Temp = eval("Test");
Drop the eval, it does nothing here. You could just write
var Temp = Test;
I would recommend
var temp = document.frames['Test'];
instead, though.

Did you mean window.frames? I honestly don't know which is the
standard, but document.frames doesn't make much sense to me (and is
undefined in FF1).

Oops, I meant "standard" (as in there is no real standard for the window
object).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top