InnerHTML question

T

Tim Haines

Hi y'all

I've been having a wee struggle tonight with some JS. It seems that
IE and Firefox both handle .innerHTML differently. If you have a div
containing a form with a checkbox, FF's call to innerHTML will always
return the checkbox "checked" status as it was when the page was first
loaded. IE's call to innerHTML will return the "checked" status as it
is when the call is made. So if you load the page, change the status,
then IE and FF will return differently values. It seems to me IE has
it right in this case - and I don't (despite googling) understand why
FF doesn't return an innerHTML string that matches the current values.

Here's a simple test case that shows it. Save the html below to a
page, and try clicking the link in FF and IE. You'll see the
different results.

Does anyone have an idea on how to get FF to return an up to date html
string that shows current input values?

<fingers crossed that emailing html with embedded js works>

Cheers,

Tim.

<html>
<head>
</head>
<body>

<div id="container">
Start Text
<form>
<input type="checkbox" id="test_cb" name="test_cb"
value="tehValue" checked="checked" />
</form>
End Text
</div>

<a href="#" onclick="alert('html inside container is: ' +
document.getElementById('container').innerHTML)">Show innerHTML</a>
</body>
</html>
 
T

Tim Streater

David Mark said:
It is best to avoid innerHTML as it is deprecated and cross-browser results
vary in several ways.


FF has it right.

Safari agrees with Firefox. Also, On IE 5.2 Mac, as you set and clear
the tickbox, it says checked="checked" initially, but changes to
checked=true later.
 
R

RobG

David said:
It is best to avoid innerHTML as it is deprecated

I'm not sure that something that has never been part of a public
standard can rightfully be called "deprecated". It is still very much
part of Microsoft's dynamic HMTL model.

and cross-browser results
vary in several ways.

Yes, it should be reserved for fairly simple purposes and tested thoroughly.

FF has it right.

Since there is no public standard for innerHTML and it's a proprietary
IE feature, it might be said that whatever IE does is "right" and
anything else is "wrong".

According to MSDN, the innerHTML property:

"Sets or retrieves the HTML between the start and end
tags of the object."

<URL: http://msdn2.microsoft.com/en-us/library/ms533897.aspx >
 
R

Richard Cornford

<snip>

There is a sense in which "deprecated" means denounced, criticised,
deplored, etc. And the use of - innerHTML - certainly is denounced,
criticised and deplored by at least some individuals. Of course that
meaning of deprecated should be avoided in a (our) context, where
"deprecated" had another well known meaning.
That's only because MS doesn't support XHTML. Deprecated is the
wrong description. "Not future-proof" is more appropriate.

Doesn't "not future-proof" pre-suppose that the future will be XHTML,
which itself assumes that Microsoft's browser will support XHTML at some
point in the future.

Remember that the W3C took the stance that they were not going to
release any more versions of HTML beyond 4.01, they then gout bogged
down in XHTML 2.0 and are now working on HTML 5. The future is often
something other than what was exepced.

Scripting with the assumption that scripts that now only ever interact
with HTML DOM can be simply dropped into XHTML DOMs at some future time
when all browser support XHTML is utterly unrealistic for anything but
the most trivial scripts. Significant differences between the two types
of DOMs include such details as XHTML DOMs being namespace aware and so
implying the need to use, say, - createElementNS - in place of -
createElement - (and the same for all the other namespace methods),
while in HTML DOMs that provide both methods you can use either (so long
as the correct namespace argument is used for HTML), and then some HTML
DOMs don't provide the NS methods. There is a whole extra layer of
testing and branching for no tangible benefit in the current
environment, but only to future-proof against a future that may never
happen.

But in reality we don not see this extra code being written, because the
people who do things like avoiding - innerHTML - and - document.write -
are only fooling themselves into thinking that they are working with
XHTML, because they serve their mark-up as text/html and all browsers
then must interpret it as (error-filled, tag-soup) HTML and provide an
HTML DOM for them to script. There is no future proofing in this. If
you are writing a script that can never successfully interact with an
XHTML DOM you may as well accept that you are scripting HTML (no matter
what the mark-up may resemble) and employ the features provided by an
HTML DOM (which still does not necessarily include - innerHTML -).
I stopped using it a while back so that my scripts will work
in HTML or XHTML documents without modification.

I am yet to see a non-trivial script that could do that in reality
without being twice the size and complexity of an HTML DOM script.
Same for innerText, outerHTML, etc. I still use document.write as I
prefer it in HTML documents, but
only through an XML-sensitive wrapper. I just can't see
churning out scripts that will fail with an XML parser.

What have XML parsers to do with - document.write -? Historically XHTML
DOMs just have not implemented - document.write - in a way that was
functional. Either throwing exceptions when it was called (with any
argument) or just not doing anything.
Which is pretty vague, but I would not have expected it to return
the states of form elements. Of course, I wouldn't expect
getAttribute to do that either. So, in IE, innerHTML is
counter-intuitive and getAttribute is broken.

There is a great deal of potential for arguing about who is right and
who is wrong. Remember that in the DOM we have Element objects that have
properties, such as - value -, and also have attribute nodes. The
attribute nodes are created from the source HTML (originally) and the
property's values are initially set based upon attribute values or
defaults.

However, take - value - with an <INPUT type="text"> element, for
example. The DOM element has - value - and - defaultValue - properties,
and both would be initialised from the VALUE attribute, but if you
change either which would be the one you would expect to be reflected in
the serialised mark-up form of the Element?

The W3C HTML DOM specifies - defaultValue - as:-

| When the type attribute of the element has the value "text",
| "file" or "password", this represents the HTML value
| attribute of the element. The value of this attribute
| does not change if the contents of the corresponding form
| control, in an interactive user agent, changes. See the
| value attribute definition in HTML 4.01.

(note: "this represents the HTML value attribute of the element")

- and - value as:-

| When the type attribute of the element has the value "text",
| "file" or "password", this represents the current contents
| of the corresponding form control, in an interactive user
| agent. Changing this attribute changes the contents of
| the form control, but does not change the value of the
| HTML value attribute of the element. When the type
| attribute of the element has the value "button", "hidden",
| "submit", "reset", "image", "checkbox" or "radio", this
| represents the HTML value attribute of the element. See
| the value attribute definition in HTML 4.01.

(Note: "this represents the current contents of the corresponding form
control")

The implication being that assigning values to the - defaultValue -
property of the Element should modify the VALUE attribute node, while
values assigned to the - value - property should only be displayed in
the field and submitted with the form.

So if your attitude is that serializing the element to mark-up is to be
based upon its attribute nodes (a reasonable stance to take) it is -
defaultValue - that needs to be modified in order for the result to be
reflected in the mark-up. While if you are planning on serializing the
properties of the Element it may be the - value - property that ends up
reflected in the mark-up. And then there is the position that modifying
the DOM Element's properties should not influence the element's
attribute nodes at all, but it may still be these nodes that will be
serialized, so you just get back out the mark-up you put in (if maybe
normalized in some sense).

And similar considerations would apply to the relationship between -
checked - and - defaultChecked -, and - selected - and -
defaultSelected - on OPTION elements.

The bottom line is that - innerHTML - is a viable means of injecting
HTML mark-up into an HTML document but trying to get anything useful out
of it is a bit of a dead end.

Richard.
 
R

RobG

Rick said:
RobG said:
David said:
Hi y'all

I've been having a wee struggle tonight with some JS. It seems
that IE and Firefox both handle .innerHTML differently. If you
have a div
It is best to avoid innerHTML as it is deprecated
I'm not sure that something that has never been part of a public
standard can rightfully be called "deprecated". It is still very much
part of Microsoft's dynamic HMTL model.

and cross-browser results
vary in several ways.
Yes, it should be reserved for fairly simple purposes and tested
thoroughly. [snip]

We have started building web apps in our company to replace both 5250 terminal
programs and various other thick client platforms. The framework we use allows
us to retrieve database data into in-memory XML documents and then we send those
through XSL style sheets to produce (sometimes fairly elaborate) HTML. We then
display that HTML on the page by setting the innerHTML of a container div with
the output of the XSL processing.

This is very fast and works very well. The one time we had a developer try to
use the dom insertion methods instead (to solve another issue) it was very
tedious and lots slower. Given that is the use of innerHTML really that bad of
an idea? We only support IE6/7 and FF1.5/2 and see nothing serious (so far)
between the two in the behavior of innerHTML.

If you are just returning slabs of HTML to be injected using innerHTML,
I would characterise that as "fairly simple" from a client-side
perspective. All the work is on the server, you are likely returning
much the same markup as if you were serving a page.

DOM methods are much more competitive when used to modify existing
elements, rather than wholesale replacement of page content.
 
A

Animesh K

David said:
It is best to avoid innerHTML as it is deprecated and cross-browser results
vary in several ways.



Related question:

I have an html file which reads off a header as <h1 id="poemtitle">Some
stuff</h1>

Right now I am calling the value "Some stuff" as
document.getElementById("poemtitle").innerHTML.

Is there any other method to call the value, since you are suggesting to
avoid innerHTML. I tried document.getElementById("poemtitle").value, but
that didn't work.
 
R

RobG

Animesh said:
Related question:

I have an html file which reads off a header as <h1 id="poemtitle">Some
stuff</h1>

Right now I am calling the value "Some stuff" as
document.getElementById("poemtitle").innerHTML.

Is there any other method to call the value, since you are suggesting to
avoid innerHTML. I tried document.getElementById("poemtitle").value, but
that didn't work.

var el = document.getElementById("poemtitle");

// W3C DOM compliant
if (typeof el.textContent == 'string') {
alert(el.textContent);

// IE and similar
} else if (typeof el.innerText == 'string') {
alert(el.innerText);
}

I have also posted a getText function that bundles the two above methods
with a recursive method to for any browser that doesn't support either
textContent or innerText if you care to search for it.
 
A

Animesh K

David said:
Related question:

I have an html file which reads off a header as <h1 id="poemtitle">Some
stuff</h1>

Right now I am calling the value "Some stuff" as
document.getElementById("poemtitle").innerHTML.

Is there any other method to call the value, since you are suggesting to
avoid innerHTML. I tried document.getElementById("poemtitle").value, but
that didn't work.

A headline is not an input element. Use something like this:

var el = document.getElementById("poemtitle");
if (el.childNodes && el.childNodes[0] && (el.childNodes[0].nodeType == 3 ||
el.childNodes[0].nodeType == 4)) alert(el.childNodes[0].nodeValue);

Otherwise use innerText.

Thanks for the responses, David, Rob, and Bolmarcich!

So how do I find our which elements are input elements and which are
not? I hope there is a place for JS just like htmldog is for html/css.

Learning something new, each day!
 
D

dhtmlkitchen

Hi y'all

I've been having a wee struggle tonight with some JS. It seems that
IE and Firefox both handle .innerHTML differently. If you have a div
containing a form with a checkbox, FF's call to innerHTML will always
return the checkbox "checked" status as it was when the page was first
loaded. IE's call to innerHTML will return the "checked" status as it
is when the call is made. So if you load the page, change the status,
then IE and FF will return differently values. It seems to me IE has
it right in this case - and I don't (despite googling) understand why
FF doesn't return an innerHTML string that matches the current values.

Here's a simple test case that shows it. Save the html below to a
page, and try clicking the link in FF and IE. You'll see the
different results.

As you figured out, the "checked" property is not the checked
attribute.

The element's "checked" attribute, e.g.
checkbox.getAttribute( "checked" ), does not represent element's
checked property, e.g. element.checked.

innerHTML all attributes of elements, not properties.

The "checked" attribute will change with a call to
checkbox.setAttribute( "checked", !checkbox.checked );

That is why there is an event for CheckboxStateChanged in XUL.
https://bugzilla.mozilla.org/show_bug.cgi?id=335020

Garrett
Does anyone have an idea on how to get FF to return an up to date html
string that shows current input values?
use the checked property. e.g.

checkboxEl.checked.

to find the defaultChecked value, use:

checkboxEl.defaultChecked
 
A

Animesh K

David said:
[snip]
Thanks for the responses, David, Rob, and Bolmarcich!

So how do I find our which elements are input elements and which are not?
I hope there is a place for JS just like htmldog is for html/css.

The tagName (or nodeName) property. I don't understand the last bit. What
is htmldog?

http://www.htmldog.com has all the html tags and CSS properties in
place. It helps as a solid reference whenever I am confused about any
html element or CSS property.

So I was asking if there is a JS website which tells these fine details
of what elements are "input elements" and what are accessible using
innertext, etc.
 
R

RobG

And speaking of which, is there any fundamental difference between:

'string' == typeof e

*or*

typeof e == 'string'

In regard to typeof tests, none. There is a school of thought that if
a test might result in an assignment if incorrectly written, it should
be coded so that the incorrect version will produce a syntax error and
be detected early, e.g.:

intended: if ( x == null ){ true branch }else{ false branch }
written: if ( x = null ){ true branch }else{ false branch }

the second will always follow the 'false' branch, regardless of the
vaule of x and may slip past testing. However, it if is written as:

intended: if ( null == x )
written: if ( null = x )

the erroneous assignment will reveal itself as a syntax error and be
easily discovered. However, in the case of typeof tests, any attempt
at assignment will fail regardless of which way it is written:

if ( typeof x = null )
if ( typeof null = x )

both produce a syntax error.
Also, did you get my response on how to sort threads from that
"newsgroup has become vicious" thread? I wasn't sure, since Google has
been misbehaving lately.

Yes, thanks!
 
R

RobG

David said:
[snip]
Thanks for the responses, David, Rob, and Bolmarcich!
So how do I find our which elements are input elements and which are not?
I hope there is a place for JS just like htmldog is for html/css.
The tagName (or nodeName) property. I don't understand the last bit. What
is htmldog?

http://www.htmldog.comhas all the html tags and CSS properties in
place. It helps as a solid reference whenever I am confused about any
html element or CSS property.

So I was asking if there is a JS website which tells these fine details
of what elements are "input elements" and what are accessible using
innertext, etc.

The answers there are simple: input elements are defined in the W3C
HTML specification, i.e. one that has a start tag <input> and no end
tag.

innerText should only be used as a fallback during feature detection.
innerText will only work for an element that has some content: any
element that has "end tag forbidden" can't have content and so can't
have innerText.

Microsoft's reference for innerText says:

"The innerText property is valid for block elements only. By
definition, elements that do not have both an opening and
closing tag cannot have an innerText property."

<URL: http://msdn2.microsoft.com/en-us/library/ms533899.aspx >

The bit about block elements seems wrong, innerText works on inline
elements too:

<p><span onclick="alert(this.innerText);">hey</span></p>

It also ambiguous regarding elements whose closing tag is optional
(and there are many of those).

I think you are better off to use the W3C specifications, they have
summary sections for HTML elements & attributes as well as CSS
properties:

HTML elements:
<URL: http://www.w3.org/TR/html4/index/elements.html >

HTML element attributes:
<URL: http://www.w3.org/TR/html4/index/attributes.html >

CSS properties:
<URL: http://www.w3.org/TR/CSS21/propidx.html >

Similarly the DOM HTML index can be very useful, the only trick is
learning which one to look at:

DOM 2 Core:
<URL: http://www.w3.org/TR/DOM-Level-2-Core/def-index.html >

DOM 2 Events:
<URL: http://www.w3.org/TR/DOM-Level-2-Events/def-index.html >

DOM 2 HTML:
<URL: http://www.w3.org/TR/DOM-Level-2-HTML/def-index.html >

DOM 2 Style:
<URL: http://www.w3.org/TR/DOM-Level-2-Style/def-index.html >

DOM 2 Traversal and Range:
<URL: http://www.w3.org/TR/DOM-Level-2-Traversal-Range/def-index.html
DOM 2 Views:
<URL: http://www.w3.org/TR/DOM-Level-2-Views/def-index.html >


While the W3C stuff isn't perfect, at least you have the comfort of
knowing what it supposed to happen where things are clearly specified
(and being aware of where things aren't clear and likely to be
problematic). It doesn't always work, but it helps.

Anything that you can't find at the W3C may be part of IE's DOM, so as
a backup, try:

MSDN HTML & DHTML reference:
<URL: http://msdn.microsoft.com/library/d...hor/dhtml/reference/dhtml_reference_entry.asp
Lastly there's always the Gecko DOM pages, which are handy because
they include DOM 0, some Gecko specific DOM stuff (but not much) and
links to W3C DOM pages where appropriate:

Gecko DOM reference:
<URL: http://developer.mozilla.org/en/docs/Gecko_DOM_Reference >
 
R

Richard Cornford

David said:

Will it really? It has been suggested that because this period of
tag-soup HTML in the guise of XHTML is letting people authoring 'XHTML'
get away with all the abuses that they previously got away with in HTML
(because in reality they are still writing tag-soup HTML) if and when
Microsoft release a browser that 'supports' XHTML it will not have a
proper XML parser but instead a parser that second guesses and
error-corrects to the extent that they avoid having to field all the
complaints from people who's 'XHTML' that had been working with IE
suddenly stops working. So out of the window goes all the imposed
discipline of well-formed XML and valid mark-up and we are back to a
status-quo of "it works in IE so why shouldn't it work in other
browser?".
Version 7 almost had it, but they ran out of time at the end.

Yes, tag-souping XML is not going to be easy for them, and so not quick.
From what I have heard, version 8 will have an XML parser.

Given the 6 year interval between versions 6 and 7 promises of version 8
are not that encouraging.

However, the release of an IE versions that supports XHTML is not the
future that present-day author of HTML grounded web projects needs to be
'future-proof' against. What that release does is mark the point where
it becomes viable to start considering creating commercial XHTML only
projects. The future that an HTML only project needs to worry about is
the one where a major stops supporting HTML, presumably (in your vision
of the future) in favour of XHTML. My judgement would be that if that
future is going to happen at all it is so far off as to be beyond the
life expectancy of any web project being considered today. And if the
W3C end up releasing an HTML 5 that is back-compatible with HTML 4, and
it terns out that HTML5is (as intended) the language of choice for web
applications, then that future recedes even further into the distance.

Then there is the (possible) future of XHTML to consider. XHTML 2 is
supposed to be modular, and if it is modular it will need a radically
different DOM specification to accommodate/employ that. The current HTML
DOM applies to XHTML 1, and may only ever apply to XHTML 1. So you write
your XHTML/HTML DOM branching scripts today and by the time IE
introduces support for XHTML and you can weed out the HTML branches,
Mozilla/Firefox has introduced support for XHTML 2, and a new XHTML 2
DOM and you are back at square one, with as much maintenance work ahead
as you would have had if you had never attempted to be "future proof" in
the first place.

Future proofing is really a non-issue in the choice of XHTML or HTML,
and it may yet turn out to be a complete red-herring.
Yes I know. I have a library that deals with this issue.

Most people don't, and really could not justify the learning,
development and testing time needed to create one, nor the code bloat,
increased maintenance costs and performance hit that would go along with
one.
That's why I only use createElement when not in XML mode.

And so knowing that you are in "XML mode" means testing for that, and
branching.
The wrappers that deal with this aren't particularly complex.

But they must be more complex than not having them at all. A strategy of
writing HTML mark-up, serving it as text/html and scripting the
resulting HTML DOM is inherently simpler. Granted writing XHTML, serving
it as application/xhtml+xm and scripting the XHTML DOM would be as
simple, but it is not yet a commercially viable option. But messing
around trying to do both, and the right one at the right time, is (and
has got to be) more complex, more error prone, and so more expensive and
less successful. KISS is a nice principle to follow.
XHTML is already here and quite useful if you know how to exploit it.

XHTML brings nothing that cannot be achieved by other means.
Granted, it isn't for everybody.

Yes, it is not for commercial web work where IE support is required.
That is not everyone, but it is certainly most of us.
Not me. I serve the XHTML type to browsers that claim to accept it.

Do you mean all browsers that claim to accept it, or just those that
either express a preference for it over HTML or an equivalent
preference? There were, for example, those early Opera 7 versions that
expressed a preference for HTML over XHTML because their XHTML DOMs
where incomplete/defective. They would render XHTML fine, but scripting
them was pretty much a non-starter (not least because they would not act
upon script elements in the mark-up).
It isn't complicated to do.

Complexity is, at least in part, a matter of perception. Applying
quality values to media ranges of varying specificity and coming to a
(correct) conclusion as to how what you have available best meats the
preferences asserted by the user-agent in its Accept headers is
certainly more complicated a problem than most would want to address if
they did not have to. And this leads to a situation were HTTP content
negotiation is abandoned in favour of the stupidly simplistic. That is,
a situation where inept developers do no more than search the Accept
header for the sub-string "application/xhtml+xm" and serve XHTML
whenever it appears. This is, of course, absolutely against the HTTP 1.1
and will result in XHTML being served to any browser that expresses its
rejection of XHTML (i.e. includes the sequence "application/xhtml+xm;
q=0" in its Accept header), and also means that User Agents expressing a
preference for HTML along side support for XHTML will be getting the
XHTML regardless.

It is at lest in part the prominence of this half-ass hack in the
"serving XHTML to browsers that support it" school that makes its
proponents look like they don't know what they are talking about. A am
assuming that when you say "it isn't complicated" you are referring to
real HTTP content negotiation not this nonsense, because talking of 'web
standards' and then throwing HTTP out of the window would be
unparalleled hypocrisy.

On another point with content negotiation; one of the obvious problems
with the dual XHTML/HTML DOM script is the testing and branching that
must go on inside the script to accommodate the two DOMs. That could be
avoided if the server could use the content-negotiation decision made
for the mark-up to serve one of two distinct scripts (for externally
referenced script resources). Unfortunately a script served with an
XHTML page has the same media types as a script served with an HTML
page, and the techniques that could otherwise have the different mark-up
types served different scripts just act to move the added complexity in
the script to the server doing extra work when serving it.
Of the major browsers, IE is the only one that gets text/html
and it has no problem with my pages. I do not convert them to proper
HTML for IE's benefit as it isn't necessary. IE couldn't
care less about the extra slashes, so why should I? And yes, I
have tested with lots of handheld devices, appliances, etc. Not
a one of them is a true SGML parser, so they don't care about the
extra slashes either. It seems the only outcry about those is
from those who are dead-set against dealing with XHTML.

The "outcry" about the slashes is about the way that their use makes
people think that they are writing (and by implication scripting) XHTML
when they are not. It really is best, in all cases, if people perceive
what they are doing as being what they are actually doing.

Look at the questions asked on this group. How often do you see someone
starting of with "I am writing XHTML" and then posting an HTML DOM
script that could never work with XHTML, even to the extent that they
say it does? Or starting with that and just asking how to do something,
when if you showed them an XHTML DOM script for the task you know they
will just go off and try it in IE and come back and say "your script
does not work", when you know dam well that in an XHTML DOM it will work
just fine.

Is it really too much to expect people to see the distinction between
XHTML and HTML? Or to expect that when they understand that they are
working exclusively with HTML they would then be then be using HTML
mark-up.

Of course as script authors we are in the fortunate position of being
able to say whether a document is HTML or XHTML without any ambiguity.
If it is an HTML document then the browser exposes and HTML DOM to be
scripted (regardless of the form of the mark-up used) and if it is an
XHML document (where supported) it is an XHTML DOM that is exposed to be
scripted, with sufficient distinctions between the two types of DOM that
nobody can be in any doubt as to which any given resulting DOM is.
Not for those people, no.


You haven't seen any of mine.

You are yet to post anything non-trivial.
Nothing at all. ...

It doesn't do anything.

What does nothing at all? Calls to - document.write - certainly do throw
exceptions in some XHTML DOMs. Because - document.write - is in the W3C
HTML DOM standard, which does apply to XHTML 1, we had a long discussion
a few years back about what XHTML DOMs should do with the calls, which
lead to testing the XHTML DOMs available at the time, and some threw
exceptions, while others did nothing, and still others omitted the
method entirely. The conclusion being the fairly obvious 'it is not even
worth trying to use - document.write - in an XHTML DOM'.

I agree with the second point, but I think anyone who uses it to
inject elements would be better off learning the standard
DOM-manipulation methods.

What makes you think that using - innerHTML - and knowing the DOM
manipulation methods are mutually exclusive? If it is mark-up that you
have to inject then writing an HTML parser that can create the
corresponding DOM fragment with the DOM manipulation methods and then
inserting it in an Element is a ridiculous effort to go to, and a
needlessly inefficient way of doing something that the browser could do
natively.

I would accept that transmitting fragments of mark-up for injection is
probably almost always a bad design decision, and so the vast majority
of cases where - innerHTML - is used to inject mark-up could, and
should, be avoided. And I am particularly unimpressed with designs where
this is carried through to the point where presentational (as opposed to
semantic) mark-up is being stored in the database for use in this
context.
As was mentioned, innerHTML is not standard and likely never
will be.

Microsoft would not implement any - innerHTML - standard that changed
what they have done historically (because they would not chose to break
half the world's Windows-based Intranets) so anyone trying to
standardise it has either got to define it as being precisely what IE
does or they may as well not waste their time. So, yes, it is never
likely to be standardised. On the other had, more browsers support -
innerHTML - (in one form or another) than support the W3C HTML DOM
standard.

Richard.
 
D

David Mark

Will it really? It has been suggested that because this period of
tag-soup HTML in the guise of XHTML is letting people authoring 'XHTML'
get away with all the abuses that they previously got away with in HTML
(because in reality they are still writing tag-soup HTML) if and when
Microsoft release a browser that 'supports' XHTML it will not have a
proper XML parser but instead a parser that second guesses and
error-corrects to the extent that they avoid having to field all the
complaints from people who's 'XHTML' that had been working with IE
suddenly stops working. So out of the window goes all the imposed
discipline of well-formed XML and valid mark-up and we are back to a
status-quo of "it works in IE so why shouldn't it work in other
browser?".

I certainly hope they do not error-correct XML. That would be nuts.
I think the tag soup people will continue to serve text/html and will
continue to use the HTML parser.
Yes, tag-souping XML is not going to be easy for them, and so not quick.


Given the 6 year interval between versions 6 and 7 promises of version 8
are not that encouraging.

I have read that they are a year away (or so.)
However, the release of an IE versions that supports XHTML is not the
future that present-day author of HTML grounded web projects needs to be
'future-proof' against. What that release does is mark the point where
it becomes viable to start considering creating commercial XHTML only

Or the point where existing XHTML applications can be served as
intended to IE. And of course you couldn't start serving XHTML-only
apps at that point. There will still be plenty of IE6/7 users to
support.
projects. The future that an HTML only project needs to worry about is
the one where a major stops supporting HTML, presumably (in your vision
of the future) in favour of XHTML. My judgement would be that if that
future is going to happen at all it is so far off as to be beyond the

I don't doubt that is far off. It isn't my main concern. I can see a
lot of future innovations involving XML that will be impossible to
leverage if your content is locked up in HTML. I don't mean that your
HTML pages will suddenly die, but that they will slowly but surely
become obsolete.
life expectancy of any web project being considered today. And if the

What do you mean by life expectancy? Web pages don't die. They get
re-tooled to leverage new innovations. The question is how much
future work are you signing up for if you continue to churn out HTML.
W3C end up releasing an HTML 5 that is back-compatible with HTML 4, and
it terns out that HTML5is (as intended) the language of choice for web
applications, then that future recedes even further into the distance.

HTML 5 looks like a crock to me. It certainly will not be my language
of choice unless XHTML 2 is aborted by the w3c (which seems doubtful.)
Then there is the (possible) future of XHTML to consider. XHTML 2 is
supposed to be modular, and if it is modular it will need a radically
different DOM specification to accommodate/employ that. The current HTML
DOM applies to XHTML 1, and may only ever apply to XHTML 1. So you write
your XHTML/HTML DOM branching scripts today and by the time IE
introduces support for XHTML and you can weed out the HTML branches,

As I mentioned above, you can't weed out the HTML branches on the
release of IE8.
Mozilla/Firefox has introduced support for XHTML 2, and a new XHTML 2
DOM and you are back at square one, with as much maintenance work ahead
as you would have had if you had never attempted to be "future proof" in
the first place.

You misunderstand. I don't write "branching scripts." I have a
compact library of wrappers that abstract the DOM variations. It will
be trivial to modify the central functions for XHTML 2 when it becomes
necessary. Contrast that with applications that have thousands of
document.write calls and innerHTML manipulations sprinkled throughout
each script.
Future proofing is really a non-issue in the choice of XHTML or HTML,
and it may yet turn out to be a complete red-herring.







Most people don't, and really could not justify the learning,

Who cares what "most people" do?
development and testing time needed to create one, nor the code bloat,
increased maintenance costs and performance hit that would go along with
one.

I think you overestimate the impact on code size, maintenance,
performance and development time. And as for testing, I can't of
anything worse to debug than innerHTML-related problems.
And so knowing that you are in "XML mode" means testing for that, and
branching.

Who said that the only rationale behind using XHTML was future-
proofing? One obvious tangible benefit is that my pages don't get
parsed as HTML.
But they must be more complex than not having them at all. A strategy of
writing HTML mark-up, serving it as text/html and scripting the
resulting HTML DOM is inherently simpler. Granted writing XHTML, serving
it as application/xhtml+xm and scripting the XHTML DOM would be as
simple, but it is not yet a commercially viable option. But messing
around trying to do both, and the right one at the right time, is (and
has got to be) more complex, more error prone, and so more expensive and
less successful. KISS is a nice principle to follow.

Of course it is more complex, but it isn't prohibitively complex. It
would be less complex to write pages without any JavaScript at all.
Where do you draw the line between simple and stupid?
XHTML brings nothing that cannot be achieved by other means.


Yes, it is not for commercial web work where IE support is required.
That is not everyone, but it is certainly most of us.

You are reaching. The original discussion was about innerHTML. I say
manipulate the DOM instead. I contend this is a good idea even if you
are writing HTML.
Do you mean all browsers that claim to accept it, or just those that
either express a preference for it over HTML or an equivalent
preference? There were, for example, those early Opera 7 versions that
expressed a preference for HTML over XHTML because their XHTML DOMs

If it expresses a preference for HTML, then it gets HTML. That's the
whole idea of content negotiation.
where incomplete/defective. They would render XHTML fine, but scripting
them was pretty much a non-starter (not least because they would not act
upon script elements in the mark-up).


Complexity is, at least in part, a matter of perception. Applying
quality values to media ranges of varying specificity and coming to a
(correct) conclusion as to how what you have available best meats the
preferences asserted by the user-agent in its Accept headers is
certainly more complicated a problem than most would want to address if
they did not have to. And this leads to a situation were HTTP content
negotiation is abandoned in favour of the stupidly simplistic.

Again, I don't really care what others do.

That is,
a situation where inept developers do no more than search the Accept

Especially inept others.
header for the sub-string "application/xhtml+xm" and serve XHTML

Yes, I have seen lots of idiotic code snippets that do exactly that.
whenever it appears. This is, of course, absolutely against the HTTP 1.1
and will result in XHTML being served to any browser that expresses its
rejection of XHTML (i.e. includes the sequence "application/xhtml+xm;
q=0" in its Accept header), and also means that User Agents expressing a
preference for HTML along side support for XHTML will be getting the
XHTML regardless.

No kidding.
It is at lest in part the prominence of this half-ass hack in the
"serving XHTML to browsers that support it" school that makes its
proponents look like they don't know what they are talking about. A am
assuming that when you say "it isn't complicated" you are referring to
real HTTP content negotiation not this nonsense, because talking of 'web
standards' and then throwing HTTP out of the window would be
unparalleled hypocrisy.

Yes, I am referring to content negotiation as documented by the w3c.
It isn't that complicated and is necessary for more than XHTML.
Certainly if you can't write a script to do proper content
negotiation, then you have no business serving XHTML.
On another point with content negotiation; one of the obvious problems
with the dual XHTML/HTML DOM script is the testing and branching that
must go on inside the script to accommodate the two DOMs. That could be
avoided if the server could use the content-negotiation decision made
for the mark-up to serve one of two distinct scripts (for externally
referenced script resources). Unfortunately a script served with an
XHTML page has the same media types as a script served with an HTML
page, and the techniques that could otherwise have the different mark-up
types served different scripts just act to move the added complexity in
the script to the server doing extra work when serving it.

I've got one small script that encapsulates all of the "testing and
branching." There is no need to split it into two. I really think
you are overstating the complexity of the problem.
The "outcry" about the slashes is about the way that their use makes
people think that they are writing (and by implication scripting) XHTML

I don't take what other people think they are writing into
consideration.
when they are not. It really is best, in all cases, if people perceive
what they are doing as being what they are actually doing.

The recurring theme seems to be that you and others are concerned
about what other people think they are doing. I just don't share that
concern.
Look at the questions asked on this group. How often do you see someone
starting of with "I am writing XHTML" and then posting an HTML DOM
script that could never work with XHTML, even to the extent that they
say it does? Or starting with that and just asking how to do something,
when if you showed them an XHTML DOM script for the task you know they
will just go off and try it in IE and come back and say "your script
does not work", when you know dam well that in an XHTML DOM it will work
just fine.

I see lots of stupid posts in this and other HTML-related groups.
There are lots of ignorant people out there developing Websites. If
XHTML ever does replace HTML, I think a lot of them would give up.
Wouldn't that be nice?
 
R

Richard Cornford

David said:
I certainly hope they do not error-correct XML.

You can hope.
That would be nuts.

Absolutely. It would make a complete nonsense out of XHTML, but is that
enough to stop Microsoft?
I think the tag soup people will continue to serve text/html
and will continue to use the HTML parser.

But the tag-soup XHML people don't know that that is what they are doing
know.
I have read that they are a year away (or so.)

Can being a "year away" now be reconciled with "Version 7 almost had it"
at the time of its release?
Or the point where existing XHTML applications can be served as
intended to IE.

If an "existing XHTML applications" is currently not being served to IE
'correctly' then it must be either an HTML application in reality (in
which case the HTML DOM scripts will mostly fail if it is served as
XHTML) or it is dual XHTML/HTML application, which is something that
hardly exists in the present climate and the wisdom of setting about
creating is precisely what we are debating.
And of course you couldn't start serving XHTML-only
apps at that point. There will still be plenty of IE6/7
users to support.

Yep, the 'future' that is XHTML is not even as close as Microsoft
starting to support it.
I don't doubt that is far off.

Which makes being 'future proof' a bit of a moot point when it comes to
XHTML.
It isn't my main concern.

But you were the person who introduced being 'future proof' as a
criteria in this discussion.
I can see a lot of future innovations involving XML that
will be impossible to leverage if your content is locked
up in HTML.

Who said the content was in the HTML? For a serious commercial project
the content is almost always in a database. What we are interested in
here is the client-side mechanism as provided by the scripting.
I don't mean that your HTML pages will suddenly die, but
that they will slowly but surely become obsolete.


What do you mean by life expectancy?

I mean that in ten years time the way in which people interact with
computers and the Internet will have changed to such an extent that the
GUI code I am writing today will no longer be wanted.
Web pages don't die. They get
re-tooled to leverage new innovations.

Yes, so why make present day design/implementation decisions that add
needless complexity to a system based on a future so far off that their
subjects will be long gone before it happens. When the need for changes
comes along the decisions about what and how to change can be made in
the light of the climate at that time.

The only thing that the future had to offer when informing current
design decisions is to suggest that change will happen, and so suggest
that designs not be so interdependent and interwoven that making changes
in the future becomes restrictively expensive.
The question is how much future work are you signing
up for if you continue to churn out HTML.

That is a pertinent question, along with how much extra work are you
signing up for now in order to avoid that hypothetical future work.
HTML 5 looks like a crock to me. It certainly will not be my
language of choice unless XHTML 2 is aborted by the w3c (which
seems doubtful.)

While my perception is that XHTML 2 is too far detached from the present
reality for it to be the next step in the development of the Internet.
As I mentioned above, you can't weed out the HTML branches on the
release of IE8.

So that would be 3 branches then? HTML, XHTML 1 and XHTML 2.
You misunderstand. I don't write "branching scripts." I have a
compact library of wrappers that abstract the DOM variations.

Whatever you say your proposal cannot work unless at some point you test
for the type of DOM and do one thing if it is an XHTML DOM and another
if it is and HTML DOM, and that is branching.
It will be trivial to modify the central functions for XHTML 2

By adding another test and another branch.
when it becomes necessary.

If it becomes necessary. I don't thing anyone has even started working
of the DOM for XHTML 2 yet.
Contrast that with applications that have thousands of
document.write calls and innerHTML manipulations sprinkled
throughout each script.

I have never seen such a scirpt.
Who cares what "most people" do?

If someone is being given advice about design decisions, such as whether
to choose to implement their front end in HTML or some duel XHTML/HTML
system the person giving the advice should be very interested in where
they start out from.
I think you overestimate the impact on code size, maintenance,
performance and development time.

I don't have to estimate the extent to which authoring a duel XHTML/HTML
system will involve more work than a pure HTML system. I only have to
observe that it must be more (which you cannot deny).
And as for testing, I can't of anything worse to
debug than innerHTML-related problems.

Not even having to do it twice?
Who said that the only rationale behind using XHTML was future-
proofing? One obvious tangible benefit is that my pages don't
get parsed as HTML.

But haven't you said that IE does parse them as (tag-soup) HTML? And it
would not be that tangible a benefit as the expected outcome is just a
rendered screen and a DOM to be scripted no matter how the mark-up is
parsed.
Of course it is more complex, but it isn't prohibitively complex.

More complex is the only issue. Complexity costs. If something is to be
more complex it should be being more complex for a good reason. There
should be a return.
It would be less complex to write pages without any JavaScript
at all.

Yes it would, and any reasonable commercial project design decisions
should be considering the cost/benefit of using client-side scripting at
all.
Where do you draw the line between simple and stupid?

The actual capabilities of an XHTML DOM are not greater than those of an
HTML DOM in any significant way. If you script and HTML you can achieve
anything that you can with an XHTML DOM, so why add the complexity of
trying to script both in parallel. The point at which the line should be
drawn is just before adding complexity that adds nothing to the outcome.
You are reaching. The original discussion was about innerHTML.
<snip>

If I am reaching are you sure you are not running and hiding?

The decision we are talking about when talking of "commercial web work "
is someone in the here and now who has a project, a budget, finite
developer and QA resources and a deadline. When it comes to DOM
scripting they have three choices:-

1. Opt for scripting the XHTML DOM, which is rejected out of hand
because IE support is required.

2. Opt to script the HTML DOM

3. Create a duel XHTML/HTML script and add content negotiation to the
servers.

3 is obviously more work than 2, and especially when you consider that
most of the developers have no familiarity with the XHTML DOM and the
abstraction layer needs to be designed, implemented and tested before
you can even start working on the final project. So if the decision is
ever going to go with 3 it is necessary to hear some really good
commercial arguments to justify it, and we are not hearing them. Future
proofing was not one, avoiding future work was not one, and the
transformability of XML is not one. Does it really come down to "my
pages don't get parsed as HTML", because that is nearer a joke than
anything else?

Richard.
 
D

David Mark

You can hope.


Absolutely. It would make a complete nonsense out of XHTML, but is that
enough to stop Microsoft?


But the tag-soup XHML people don't know that that is what they are doing
know.



Can being a "year away" now be reconciled with "Version 7 almost had it"
at the time of its release?

A year away from releasing IE8. I assume they have other concerns
besides implementing an XML parser.
If an "existing XHTML applications" is currently not being served to IE
'correctly' then it must be either an HTML application in reality (in
which case the HTML DOM scripts will mostly fail if it is served as
XHTML) or it is dual XHTML/HTML application, which is something that
hardly exists in the present climate and the wisdom of setting about
creating is precisely what we are debating.

Right. In other words, Web applications that support both will go
from being mostly interpreted as HTML to mostly interpreted as XHTML.
Not overnight of course as not everybody will adopt IE8 immediately.
Eventually, the HTML portion can be short-circuited, which will take
about five seconds as it exists in only one script.
Yep, the 'future' that is XHTML is not even as close as Microsoft
starting to support it.

For my purposes it is already here. No matter what you say, I don't
think innerHTML is a good idea (getting back on the original topic.)
That goes for the present, past and future.
Which makes being 'future proof' a bit of a moot point when it comes to
XHTML.

Not at all. See below.
But you were the person who introduced being 'future proof' as a
criteria in this discussion.

"Future proof" implies more than just guarding against catastrophic
failure in the future.
Who said the content was in the HTML? For a serious commercial project
the content is almost always in a database. What we are interested in

I don't agree with that at all. Some of the text may be in a
database, but certainly not the markup.
here is the client-side mechanism as provided by the scripting.

Er. The scripting isn't in a database either. I didn't make the leap
in logic between the last two sentences.
I mean that in ten years time the way in which people interact with
computers and the Internet will have changed to such an extent that the
GUI code I am writing today will no longer be wanted.

Perhaps not, but what does that have to do with the price of beans in
Somalia?
Yes, so why make present day design/implementation decisions that add
needless complexity to a system based on a future so far off that their
subjects will be long gone before it happens. When the need for changes
comes along the decisions about what and how to change can be made in
the light of the climate at that time.

Since you have never (to my knowledge) reviewed a single design or
line of code of mine, I have to figure you really don't know what you
are talking about. So I agree to disagree about all of the "needless
complexity" assumptions.
The only thing that the future had to offer when informing current
design decisions is to suggest that change will happen, and so suggest
that designs not be so interdependent and interwoven that making changes
in the future becomes restrictively expensive.

Right. I am sure I am covered for whatever the future may bring. As
for those who churn out one app after another with lots of innerHTML
manipulations woven into them, lots of luck!
That is a pertinent question, along with how much extra work are you
signing up for now in order to avoid that hypothetical future work.



While my perception is that XHTML 2 is too far detached from the present
reality for it to be the next step in the development of the Internet.

You make it sound like a race to be the next step. Who is to say if
the next step will be significant? Looking more than one step ahead,
I see XHTML 2 as a step in the right direction and HTML 5 as a passing
waste of time.
So that would be 3 branches then? HTML, XHTML 1 and XHTML 2.

Yes, inside a few core functions. So what? Up until recently, most
Web apps have defined three branches for getElementById. More
recently that has dropped to two. It's the same sort of thing for
createElement. What's the big deal?
Whatever you say your proposal cannot work unless at some point you test
for the type of DOM and do one thing if it is an XHTML DOM and another
if it is and HTML DOM, and that is branching.


By adding another test and another branch.


If it becomes necessary. I don't thing anyone has even started working
of the DOM for XHTML 2 yet.


I have never seen such a scirpt.

Aren't you the lucky one? Okay, maybe hundreds per script, but add
them all up and you've got a mess that is hard to follow and
impossible task to convert them to anything in the future. BTW, does
HTML5 define a standard for innerHTML?
If someone is being given advice about design decisions, such as whether
to choose to implement their front end in HTML or some duel XHTML/HTML
system the person giving the advice should be very interested in where
they start out from.



I don't have to estimate the extent to which authoring a duel XHTML/HTML
system will involve more work than a pure HTML system. I only have to
observe that it must be more (which you cannot deny).


Not even having to do it twice?

Having to do what twice? You test once in every browser, regardless
of whether you use innerHTML or not. For example, you don't need to
test XML in IE (can't) and you don't need to test HTML in Mozilla
(unless you are worried about users saving your documents with an
incorrect extension and then trying to run your application from their
local file system.)
 
R

Richard Cornford

David said:
Right. In other words, Web applications that support both
will go from being mostly interpreted as HTML to mostly
interpreted as XHTML.

At the same time as a pure HTML application goes from being entirely
interpreted as HTML to being entirely interpreted as HTML.
Not overnight of course as not everybody will adopt IE8
immediately.

No they will not. We have corporate customers in America who are
reluctant to roll out IE 7 for fear that it will break their existing
Intranet applications. Which is a pity as it will not break the web
applications we sell them, and IE 7 really is much faster than IE 6 at
executing (particularly big) scripts.
Eventually, the HTML portion can be short-circuited,
which will take about five seconds as it exists in
only one script.

So you are still proposing distributing the HTML DOM code after it
becomes redundant. Else its removal will take more that five seconds
(and should imply another round of QA regression testing).
For my purposes it is already here. No matter what you say,
I don't think innerHTML is a good idea (getting back on the
original topic.) That goes for the present, past and future.

HTML DOM scripting does not necessitate the use of - innerHTML -,
it just does not preclude it. It is not a 'one thing or the
other' situation.
Not at all. See below.

See what precisely below?
"Future proof" implies more than just guarding against
catastrophic failure in the future.

Yes, it also implies things like guarding against excessive costs
following from inevitable change. But as we have seen, at the point
where your proposed dual HTML/XHTML application is being exposed to a
new and untried XHTML DOM implementation, when the script is being
modified to remove the redundant HTML branches and when the servers are
benign re-configured to remove the now redundant content negotiation, my
HTML DOM only scripts are soldering on just as they always have, in a
mature environment.
I don't agree with that at all. Some of the text may be in a
database, but certainly not the markup.

How does the content being in the database imply that the mark-up (and
which mark-up, I assume you mean HTML mark-up, as opposed to XML mark-up
designed with application-specific semantics) is in the database?
Er. The scripting isn't in a database either.

No, that is where the contents are, as I said.
I didn't make the leap
in logic between the last two sentences.

I am not sure whether that is a true statement.
Perhaps not, but what does that have to do with the price of
beans in Somalia?

It means that when I am making decisions today knowing that in 10 years
time everything that is created today will have been replaced I know
that I do not have to consider circumstances that may come into
existence in 11 or more years time. Even if in five years time I would
make a different decision that sill would not make the decision made
today wrong.
Since you have never (to my knowledge) reviewed a single design
or line of code of mine, I have to figure you really don't know
what you are talking about.

How exactly is reviewing a single line of your code supposed suddenly
confer the quality of knowing what I am talking about?
So I agree to disagree about all of the "needless
complexity" assumptions.

If you disagree then that is just because you refuse to recognise that
the complexity that must be added when choosing a dual XHTML/HTML DOM
design over a pure HTML DOM design either is needles or is complexity.

There is no real question that code that is to execute HTML DOM methods
under one set of circumstances and XHTML DOM code under another is, at
some point, going to have to make a test to determine which it is going
to use, and branch based upon the result of that test. Code that tests
and branches is more complex that code that does not test and branch. It
may not have to be that much more complex, but it must be complexity
that is added as a consequence of attempting to create a system that
will operate with both XHTML DOMs and HTML DOMs.

That is without the content negotiation, where my reason for pointing
out that it is commonly done so badly that it violates HTTP and can
produce the opposite of the specified outcome was to show that however
uncomplicated you may perceive that as being for many it is too complex
to implement effectively at all. It is certainly more complex than only
offering HTML and so only serving text/html.

As to whether the added complexity is needless; if a system is to be
dual XHTML/HTML system then it follows that everything that it must do
must be doable with HTML. So there is no need for it to get involved
with XHTML at all in order to get the job done. That makes the XHTML
optional, a design choice, not a necessity.
Right. I am sure I am covered for whatever the future may bring.

Probably one of the consequences of your being so certain about what the
future will be.
As for those who churn out one app after another with lots of
innerHTML manipulations woven into them, lots of luck!

The consequences of bad design decisions will tend to be bad, but
questioning the wisdom of attempting to create a dual XTHML/HTML system
does not imply creating a systems with "lots of innerHTML manipulations
woven into them".
You make it sound like a race to be the next step.
Who is to say if the next step will be significant?

It is significant for the question of future proofing. If web browsers
are implementing HTML 5 (with back-compatibility with HTML 4) while
XHTML 2 is still being argued about the future for present day HTML DOM
scripts is considerably extended.
Looking more than one step ahead, I see XHTML 2 as a step
in the right direction and HTML 5 as a passing waste of time.

Idealism verses pragmatism. XHTML 2 ultimately may be the best hypertext
mark-up system ever devised, but the current practical desire is to put
a more capable GUI onto web applications (or to do so without jumping
through too many hoops).
Yes, inside a few core functions. So what?

Needless added complexity.
Up until recently, most Web apps have defined three branches
for getElementById.

No, not web applications. Three branches were to accommodate Netscape 4,
IE 4 and more recent DOM standard browsers. You won't find many web
applications that were even considered viable on Netscape 4, those three
branches where for compatibility in public web sites and e-commerce
sites. There were also a bad thing that everyone is happy to see the
back of and don't want to be re-introducing without a very good reason.
More recently that has dropped to two.

Or one.
It's the same sort of thing for
createElement. What's the big deal?

Those branches existed to maximise the support for actively scripted
interactions on web browsers that were in use. They followed from an
unavoidable reality. Your branches follow from a design decisions that
is increasingly looking arbitrary, and can be avoided just by making a
different decision (where there appear to be no negative consequences
following form making that different decision).
Aren't you the lucky one?

Not lucky if such scripts do not exist.
Okay, maybe hundreds per script,

Ah, so you don't think that scripts containing thousands of -
document.write - statements exist either?
but add them all up and you've got a mess that is hard to
follow and impossible task to convert them to anything in
the future.

Yes, you have got a script created by someone who is not qualified to
call themselves a programmer and could not cope the creating anything
bigger than 3 or 4 thousand statements. These people are not the people
creating web applications, because that task is beyond their abilities.
Ask the same people to write XHTML DOM scripts and you would be in
exactly the same position.
BTW, does
HTML5 define a standard for innerHTML?
Unlikely.



Having to do what twice?

Debug an innerHTML-related problem.
You test once in every browser,

Don't be silly there are hundreds of web browsers.
regardless of whether you use innerHTML or not.
For example, you don't need to test XML in IE (can't)
and you don't need to test HTML in Mozilla (unless you
are worried about users saving your documents with an
incorrect extension and then trying to run your
application from their local file system.)

If a 'web application' can be run form the local file system then it
probably should never have been a web application to start with (if the
server's role is not important then why a client-server design?).

The thing to worry about with browsers that understand XHTML and HTML
would be the user changing the configuration so that the Accept headers
were different (asserted a preference for HTML over XHTML). If that were
a possibility then it would be necessary to test both types of DOM on
any browser that provided both.

But the impact on testing does not necessarily come with the number of
environments/configurations in which it may be necessary to test, but
with the consequences of the changes that follow from finding bugs while
testing. When you test and branch in code it becomes important whether a
bug fix is upstream of a branch or downstream. If it is downstream does
the same fix need to be done in the other branch, or a similar/related
fix, or is the other branch bug free, or has different (as yet unseen)
bugs?

In the end you can only say that the differences between choosing a dual
XHTML/HTML design over the pure HTML design that does the same job are
small. but there are differences, and those differences are in the
direction of adding complexity (to staff recruitment/training, to
scripts, to mark-up creation/generation, to content negation, to
testing). So the question remains, given the consequences of the dual
XHTML/HTML path are added complexity what precisely is the return that
compensates? It was not future proffering, and it certainly was not your
'my pages are parsed by an XML parser' (which is not actually true under
this design, and the supposed 'benefits' are somewhat intangible
anyway).

Richard.
 
D

David Mark

At the same time as a pure HTML application goes from being entirely
interpreted as HTML to being entirely interpreted as HTML.


No they will not. We have corporate customers in America who are
reluctant to roll out IE 7 for fear that it will break their existing
Intranet applications. Which is a pity as it will not break the web
applications we sell them, and IE 7 really is much faster than IE 6 at
executing (particularly big) scripts.


So you are still proposing distributing the HTML DOM code after it
becomes redundant. Else its removal will take more that five seconds
(and should imply another round of QA regression testing).



HTML DOM scripting does not necessitate the use of - innerHTML -

I know that, but that was the original topic of the thread.

[snip]
How does the content being in the database imply that the mark-up (and
which mark-up, I assume you mean HTML mark-up, as opposed to XML mark-up
designed with application-specific semantics) is in the database?

Because we are talking about which markup to use. Obviously the fact
that content may be pulled from a database has no bearing.
No, that is where the contents are, as I said.

Which has no bearing on the discussion from my point of view. Think
in terms of a tool that queries your Web server and retrieves marked
up content. If it is XML, you can do a lot with it, but if the
content is "locked up" in HTML markup (regardless of how it got
there), you can't do much but parse it with regular expressions, which
is pretty useless.
I am not sure whether that is a true statement.

I am.
It means that when I am making decisions today knowing that in 10 years
time everything that is created today will have been replaced I know
that I do not have to consider circumstances that may come into
existence in 11 or more years time. Even if in five years time I would
make a different decision that sill would not make the decision made
today wrong.

I don't think ten years ahead either. That would be nuts and I don't
see how it applies to this thread.
How exactly is reviewing a single line of your code supposed suddenly
confer the quality of knowing what I am talking about?

When you are talking about the relative complexity and/or reliability
of my code. I don't see how you can comment without seeing it.

[snip]
The consequences of bad design decisions will tend to be bad, but
questioning the wisdom of attempting to create a dual XTHML/HTML system
does not imply creating a systems with "lots of innerHTML manipulations
woven into them".

My original comment was about the use of innerHTML. That's what lead
to this whole HTML vs. XHTML discussion.

[snip]
Yes, you have got a script created by someone who is not qualified to
call themselves a programmer and could not cope the creating

No kidding.

anything
bigger than 3 or 4 thousand statements. These people are not the people
creating web applications, because that task is beyond their abilities.

The term "Web application" is not strictly defined. Do you think that
a page that imitates a desktop applications, but does not contain
thousands of lines of JS is a Web application? I don't think the size
of the code has anything to do with it.
Ask the same people to write XHTML DOM scripts and you would be in
exactly the same position.

I don't ask them to do anything, but I sometimes clean up after them.
Unlikely.

That's what I thought. So my original assertion about the use of
innerHTML was true after all. It is hardly future-proof, regardless
of which version of the future comes first. All of this other
discussion about XHTML vs. HTML vs. XHTML/HTML was irrelevant.
Debug an innerHTML-related problem.

Why would I have to do that twice? I don't use it. Problem solved.
Don't be silly there are hundreds of web browsers.

If not thousands!

You have to realize that means every browser you can get your hands
on.
If a 'web application' can be run form the local file system then it
probably should never have been a web application to start with (if the
server's role is not important then why a client-server design?).

I was only making the point that you don't have to test your HTML DOM
code in browsers that accept XHTML (unless you are worried about the
something you shouldn't be worried about.) And with a base href,
virtually any Web app can run locally.
The thing to worry about with browsers that understand XHTML and HTML
would be the user changing the configuration so that the Accept headers
were different (asserted a preference for HTML over XHTML). If

That's another case you shouldn't be worried about, but is a more
likely case than running from the local file system. Changing the
accept header of your browser is not a good idea. It isn't along the
same lines as changing the user agent header.

that were
a possibility then it would be necessary to test both types of DOM on
any browser that provided both.

Yes, there are two possibilities now for Mozilla (and its clones),
Opera, Safari, Netscape, etc. Neither are likely scenarios, but you
could test them in HTML mode just to be sure.
But the impact on testing does not necessarily come with the number of
environments/configurations in which it may be necessary to test, but
with the consequences of the changes that follow from finding bugs while
testing. When you test and branch in code it becomes important whether a
bug fix is upstream of a branch or downstream. If it is downstream does
the same fix need to be done in the other branch, or a similar/related
fix, or is the other branch bug free, or has different (as yet unseen)
bugs?

I understand all of that. As I think I mentioned at some point in
this thread (or perhaps a recent similar thread), XHTML is not for
everybody (and supporting it and HTML at the same time is certainly
not for everybody.)
In the end you can only say that the differences between choosing a dual
XHTML/HTML design over the pure HTML design that does the same job are
small. but there are differences, and those differences are in the
direction of adding complexity (to staff recruitment/training, to

No. Staff that uses such a library is shielded from its
complexities. That is why the library exists.
scripts, to mark-up creation/generation, to content negation, to

My server side content negotiation script was written around the turn
of the century and hasn't changed much since then. I originally used
it to deal with WML devices and perhaps in the future I will use it
for other MIME types. It is a generalized function and no more than a
dozen lines long.
testing). So the question remains, given the consequences of the dual
XHTML/HTML path are added complexity what precisely is the return that
compensates? It was not future proffering, and it certainly was not your
'my pages are parsed by an XML parser' (which is not actually true under

Of course my pages are parsed as XML in browsers that have an XML
parser as they are served to such browsers with an XML MIME type.
this design, and the supposed 'benefits' are somewhat intangible
anyway).

For XML, they parse faster and the results are more predictable than
parsing them as "tag soup." For browsers that use the HTML parser (eg
IE), I avoid breaking them without having to write two completely
different applications. I realize it is hard for you to digest this
properly without actually reviewing an example. I can probably help
you with that in the near future.

Anyway, to get back to the original point. I still say that using
innerHTML is a bad idea. I don't use it at all and am sure it is
never needed. Why paint yourself into that corner? As for
document.write, I still use that for HTML parsers as it is more
reliable and faster than inserting into the HTML DOM during the page
load, but I only do this when I am sure that I can. That's what my
wrappers are for. The system works. You'll just have to take my word
for it for the moment. Or not. I am a bit tired of arguing about it.
 

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

No members online now.

Forum statistics

Threads
474,262
Messages
2,571,047
Members
48,769
Latest member
Clifft

Latest Threads

Top