Just thought I'd comment on these because I looked at both of the scripts. Lchad, the article you linked to is strange... It's basically using JavaScript to sidestep
XHTML validation. It's tricking validators into thinking that there is no target attribute anywhere, when in reality,
JS is placing them behind their backs.
Karinne's link provides a rather bloated script. I prefer this:
- Code: Select all
var Popups = {
init: function() {
if(!document.getElementsByTagName) {
return false;
}
var links = document.getElementsByTagName("a");
for(var i=0; i < links.length; i++) {
if(links[i].className.match("popup")) {
links[i].onclick = Popups.handle;
}
}
},
handle: function() {
window.open(this.href);
return false;
}
}
window.onload = Popups.init;
Just add class="popup" to any link and it'll open in a new window.