Quote:
|
The point of this script is to hide links that use Javascript if it's not supported.
|
Erm…
I think you mean 'to present js-dependent links only to users with js', right?
Two points. when using the setAttribute method to set a class name, IE requires you to use
className.
i.e. [i]obj.setAttribute('className','blah');
It's one of IE's many *charming* foibles.
Due to these foibles, many regard it better (read: mroe straight-forward) to take the 'DOM 0' approach.
i.e.
obj.className = 'blah';
It enjoys better browser support, both in terms of x-browser and backward compatibility.
Secondly, if you are using js to create links which use a popup window, it would be preferably if you were to create the links as usual in the markup, and then overlay some js to divert the link to a popup for those users with js.
Users without js will still be able to use the link. It will simply open in the current window.
It's referred to as 'progressive enhancement'.
e.g.
Code:
window.onload = doIt;
function doIt() {
var allLinks = document.getElementsByTagName('a');
for (var i = 0, thisLink; thisLink = allLinks[i]; i++) {
if (thisLink.className == 'popup') {
thisLink.onclick = function() {
var newWin = window.open(this.href,'popup','width=320,height=320');
return false;
}
}
}
}
…
<a href="http://www.google.com/" class="popup">Google</a>
You should endeavour to notify users when a link is going to open in a new window.
To this end, you might at least, additionally consider adding some padding-right and a new window icon for the .popup class in your stylesheet.
(There is much more you can do to enhance new window links and make the more flexible and degradable.
e.g.)