Kiran Makam wrote:
I am setting the content of a div dynamically using innerHTML
property. If the content contains an ampersand, text after the
ampersand is disappearing in IE6. It works properly in Firefox.
It works properly in both UAs, because there is no public standard that
defines how syntax errors MUST be handled. The HTML 4.01 Specification only
makes suggestions in that regard:
<http://www.w3.org/TR/1999/REC-html401-19991224/appendix/notes.html#h-B.1>
This is my code:
----------------
<body>
The DOCTYPE declaration and the required `title' element are missing.
<div id='div1'></div>
<script>
The #REQUIRED `type' attribute is missing.
var div = document.getElementById('div1');
You should do feature tests before you call anything.
div.innerHTML = "A&B";
See below.
</script>
</body>
---------------
IE6 renders the content of div1 as 'A'
That is correct.
Firefox renders the content properly as 'A&B'
That is also correct.
If there is a space after ampersand, IE6 renders it properly.
And that is correct as well.
So I think that IE is assuming anything after ampersand as an HTML entity
( like ).
Which is standards compliant.
Is this a bug in IE6?
No, the bug is in your code.
Is there any workaround for this?
Either
&
or (better) using standards-compliant properties instead of the proprietary
`innerHTML' property.
Validate your code before you complain about browsers next time.
<http://validator.w3.org/>
<http://jibbering.com/faq/>
PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>