JavaScript
Article
By Sam Deering

jQuery Cleanly Open Links in Popup Windows

By Sam Deering

Simple jQuery code snippet to add an event to all links with class .popup to open in a popup window instead of the current page or new tab/window. Specify the heights and widths as you please.

--ADVERTISEMENT--

jQuery(document).ready(function($) {
	jQuery('a.popup').live('click', function(){
		newwindow=window.open($(this).attr('href'),'','height=200,width=150');
		if (window.focus) {newwindow.focus()}
		return false;
	});
});
Recommended
Sponsors
The most important and interesting stories in tech. Straight to your inbox, daily. Get Versioning.
Login or Create Account to Comment
Login Create Account