Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / August 2007



Tip: Looking for answers? Try searching our database.

ul innerHTML in EX

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mel - 31 Aug 2007 20:47 GMT
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 - 01 Sep 2007 00:10 GMT
>         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>
[quoted text clipped - 7 lines]
>
>         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
Signature

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

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.