Re: HTML 4.01 Transitional validation



Dylan Parry wrote:

document.onload = addOptions;

Completely proprietary, and even deprecated there (in favor of
`window.onload'). Standards compliant would be

document.body.addEventListener('load', addOptions, false);

However, HTML already provides the means.

function addOptions() {
var select = document.getElementById("light");

for (i = 0; i < 9; i++) {
^
Undeclared identifier which due to the assignment becomes a property
of the Global Object or breaks the script (depending on the DOM).

var option = document.createElement("option");
option.text = i+1;
option.value = i+1;
select.appendChild(option);
}
}

That may be the standards compliant approach, but it is not cross-browser,
and it is known to fail. Probably it is better to create Option elements
(from JavaScript/JScript 1.0+), and add them to the HTMLSelectElement
object's `options' collection:

<head>
...
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script type="text/javascript">
function addOptions(sForm, sSelect)
{
var select = document.forms[sForm].elements[sSelect];

for (var i = 0; i < 9; i++)
{
select.options[select.options.length] = new Option(i + 1, i + 1);
}
}
</script>
...
</head>

<body onload="addOptions('myForm', 'mySelect');">
...
</body>


PointedEars
--
There are two possibilities: Either we are alone in the
universe or we are not. Both are equally terrifying.
-- Arthur C. Clarke
.



Relevant Pages

  • Re: HTML 4.01 Transitional validation
    ... HTML already provides the means. ... Undeclared identifier which due to the assignment becomes a property ... Probably it is better to create Option elements ... (from JavaScript/JScript 1.0+), and add them to the HTMLSelectElement ...
    (comp.lang.javascript)
  • Re: OT, but you guys know everything!!! What web page design software should I use?
    ... I strongly suggest that you consider dropping FrontPage and migrating to its successor Expression Web. ... The main problem I've had with FP is that it tends to generate HTML that isn't standards compliant. ... If you know what you are doing then FrontPage is fine, because you can keep an eye on the HTML and correct it. ... Whilst may errors don't really matter, some can cause search bots to balk which will stop search engines from finding your site or parts of your site. ...
    (microsoft.public.windows.server.sbs)
  • Re: How can I play midi and/or audio files?
    ... I have never seen a satisfactory answer to playing sound files ... Displays even if client-side script support and DOM support is not ... There is no `embed' element in HTML, so this is not supposed to work in a ... also support the standards compliant `object' element, ...
    (comp.lang.javascript)
  • Re: HTMLPurifier - Standard Compliant HTML Filtering
    ... Ambush Commander: ... but the resulting HTML is standards-compliant! ... Do you mean standards compliant, ... guess or somehow infer what any invalid markup was intended to mean ...
    (comp.lang.php)
  • Re: Why Does Your Business Need A Website?
    ... <snip SPAM> ... And what HTML version is your website? ... Do you even write standards compliant ...
    (uk.comp.vendors)

Loading