W3C home > Mailing lists > Public > www-dom@w3.org > July to September 2008

RE: Using DOM to replace media attribute in the link tag on page load

From: David Perrell <davidp@hpaa.com>
Date: Tue, 22 Jul 2008 07:48:07 -0700
To: "Patrick Garies" <pgaries@fastmail.us>
Cc: <www-dom@w3.org>
Message-ID: <HIEDLECHAFDEPLGKECDDCEIJAFAB.davidp@hpaa.com>

Patrick Garies:
| The original code was correct. |mediaType[x]| (not |mediaType.item[x]|) 
| is an ECMAScript alternative.
...
| That would be |getElementById| (with a lowercase ā€œdā€).

My apologies, thanks for the correction. I had tested before I wrote that, and it initially appeared that Jonathan's code didn't work, while mediaType[x] and getElementById("linkid") without the loop did work. But when I tested thusly:

<script type="text/javascript">
window.onload=function() {
  var mediaType = document.getElementsByTagName("link");
  for(var x=0; x<mediaType.length; x++) {
    mediaType.item(x).setAttribute("media", "all");
    alert(mediaType.item(x).getAttribute("media"));
  }
}
</script>

media type was changed in FF 3.01, Opera 9.51, and IE 5.01.

| * The MIME type text/javascript is deprecated in favor of the MIME types 
| application/javascript and application/ecmascript. Unfortunately, 
| neither are supported in Windows Internet Explorer up to version 7.

I'm still seeing a lot of pre-XP Windows with IE < 7 in my web server logs. It'll be a while before implementation of that change is a good idea.
Received on Tuesday, 22 July 2008 14:49:30 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:59 GMT