Re: standards-compliant equivalent of innerHTML
On Nov 26, 2:37 am, Andy Fish <ajf...@blueyonder.co.uk> wrote:
> > That is not what I read. I read a procession of reports from
> > individuals who have no idea of how to analyse a problem and a certain
> > amount of speculation.
>
> ok, I'll go back and have a closer look. from what I could see, the
> examples (or at least some of them) in those posts should definitely
> have worked
What is required is a definite statement of the issue and a minimal
example that demonstrates it.
From reading posts on the web and my limited testing, IE seems to have
an issue if updating the innerHTML property of an element results in
invalid markup. Here is a simple test case:
<div>
<p id="p0"></p>
<input type="button" value="Update inneHTML" onclick="
var p0 = document.getElementById('p0');
p0.innerHTML = '<li>I am an li</li>';
">
</div>
If the above is placed in a valid HTML document, clicking the button
will result in the innerHTML of the p element being set to invalid
markup. Firefox inserts an li element and displays the text, IE throws
an "Unknown runtime error".
> > Again, that should be questioned. If it is not a full document how
> > can it be validated, and if it is a full document inserting it into
> > another certainly will result in invalid mark-up. You know something
> > about these fragments, but so far you have not said exactly what it is
> > that you know about them.
>
> ok although i accept the argument that a fragment of HTML cannot be
> said to be valid HTML in isolation, i thought I made it clear when I
> said that the resultant document was valid HTML. in other words, if
> you simply did a text substitution to replace the fragment, the result
> would be a valid HTML document
If you can demonstrate that, then post sample code or link.
You seem to want to be able to insert any HTML fragment into your
document and have the browser deal with it. That seems like an
unreasonable expectation.
If you want to insert HTML fragments into documents then you must
either:
1. Impose a restriction that fragments must result in a valid document
when inserted into, say, a div element (e.g. a fragment can't start
with an li tag)
or
2. You must inspect the first tag of the fragment and, depending on
the element that will become its parent, wrap the fragment in a
suitable element so that when it is inserted in the document the
result is valid markup
As for XML or XHTML, if you aren't going to use HTML you might as well
use JSON.
--
Rob
|