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

ul innerHTML in EX

0 views
Skip to first unread message

mel

unread,
Aug 31, 2007, 3:47:50 PM8/31/07
to
Hi all,

One more of the strange things IE does differently than FF.

<html>
<body>
<ul id="ae">
<li>AEEE</li>
<li>AEEE2</li>
</ul>
<script language="javascript">
alert(document.getElementById("ae").innerHTML);
</script>
</body>
</html>

alerts correctly in FF

<li>AEEE</li>
<li>AEEE2</li>


and alerts weirdly in IE.

<li>AEEE
<li>AEEE2</li>

any ideas why and how to turn around it ?

Thomas 'PointedEars' Lahn

unread,
Aug 31, 2007, 7:10:52 PM8/31/07
to
mel wrote:
> One more of the strange things IE does differently than FF.

Complaining about inconsistent or allegedly inexplicable behavior of
browsers but not even providing them with Valid markup (let alone knowing
the basics of the used markup language) is a silly thing to do.

http://diveintomark.org/archives/2003/05/05/why_we_wont_help_you

> <html>

Missing DOCTYPE declaration; triggers Quirks/Compatibility Mode.

> <body>
> <ul id="ae">
> <li>AEEE</li>
> <li>AEEE2</li>
> </ul>
> <script language="javascript">

The `language' attribute has been deprecated long since in favor of the
`type' attribute; setting the latter is mandatory.

http://validator.w3.org/

> alert(document.getElementById("ae").innerHTML);
> </script>
> </body>
> </html>
>
> alerts correctly in FF
>
> <li>AEEE</li>
> <li>AEEE2</li>
>
>
> and alerts weirdly in IE.

There is nothing weird or incorrect about that.

> <li>AEEE
> <li>AEEE2</li>
>
> any ideas why

The `li' element has an optional close tag in HTML, and the read-value of
the proprietary `innerHTML' property is the product of an HTML serialization
of the document tree, not an exact representation of the used markup.

http://www.w3.org/TR/html401/struct/lists.html#h-10.2

> and how to turn around it ?

Don't use `innerHTML'.


PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16

0 new messages