Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

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

2 views
Skip to first unread message

Oliver Gargour (Garwin)

unread,
Feb 7, 2010, 6:43:52 AM2/7/10
to
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>


Lasse Reichstein Nielsen

unread,
Feb 7, 2010, 7:14:37 AM2/7/10
to
"Oliver Gargour \(Garwin\)" <oli...@garwin.be> writes:

> 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
--
Lasse Reichstein Holst Nielsen
'Javascript frameworks is a disruptive technology'

David Mark

unread,
Feb 9, 2010, 6:57:12 PM2/9/10
to
Lasse Reichstein Nielsen wrote:
> "Oliver Gargour \(Garwin\)" <oli...@garwin.be> writes:
>
>> 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).

David Mark

unread,
Feb 9, 2010, 6:58:03 PM2/9/10
to

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

0 new messages