View Single Post
  #5 (permalink)  
Old Jan 14th, 2007, 02:08
Ryan Fait's Avatar
Ryan Fait Ryan Fait is offline
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Validating target

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.
Reply With Quote