ul innerHTML in EX

M

mel

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 ?
 
T

Thomas 'PointedEars' Lahn

mel said:
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

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
 

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

Forum statistics

Threads
474,157
Messages
2,570,879
Members
47,413
Latest member
KeiraLight

Latest Threads

Top