Forum Moderators: open
<script for="MediaPlayer" event="Buffering(bStart)" type="text/javascript">
progressText.innerHTML = "Loading...";
</script>
The "for" and "event" attributes are keeping my XHTML from validating. I'm quite new to JavaScript, but I'm sure there's a way to get rid of them and have that stuff within the script itself. I just don't know how to do it. Could someone show me how or point me to a reference? Thanks in advance.
This could be a complicated issue. The form of event handler/script assignment you have quoted is definitely IE-only, as you know. It's rarely used outside MS demos and applications.
There are a number of ways of assigning event handlers to a particular function (not script block, as posted). The traditional is to use HTML event handlers. Trouble is that XHTML only validates particular events.
You could try assigning event handlers via Javascript, but you best wait until the page has downloaded, then, eg:
myElement.onclick = functionRef
..is one way.
What kind of syntax you use for your buffer event I don't know (it seems to have brackets in for a start). Also, when the page has downloaded, the buffering event may have already fired.
Unless there are other ideas around, I'd (shock, horror) not bother with validation with respect to that particular attribute. All you miss out on is the W3C badge (just my opinion).
Of course, non-IE browsers will execute that script block immediately, so if you're going cross-browser, something needs to be sorted out.