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>

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");

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 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:50:37 UTC