/** * Blanktarget: a jQuery Plugin to open links in new windows * @author: Rickard Sjoquist * @published: 30/06/2009 * @updated: 30/06/2009 * @requires: jQuery v.1.2.6 or above */ if(typeof jQuery != 'undefined') { jQuery(function($) { $.fn.extend({ blanktarget: function(options) { var settings = $.extend({}, $.fn.blanktarget.defaults, options); return this.each( function() { if($.fn.jquery < '1.2.6') {return;} var $a = $(this); if($a.attr('href')!='undefined') { /** * Get the URL */ var $href = $a.attr('href'); /** * Setup the Container * Add the 'container' class defined in settings * @event hover * @event click */ if(settings['settarget'] == true || settings['settarget'] == 'true') { $a.attr('target','_blank'); } else { $a.click( function(){ /** * Clicked! * The Container has been Clicked * Open the Link in a new window */ options = ""; for(attr in settings) { if( attr != 'title' && attr != 'settarget' && settings[attr] != null ) { options += (options!=''?',':'')+attr+'='+settings[attr]; } } window.open($href,settings['title'],options); return false; } ); } } } ); } }); /** * Plugin Defaults */ $.fn.blanktarget.defaults = { 'settarget' : null, 'width' : null, 'height' : null, 'title' : null, 'status' : null, 'toolbar' : null, 'location' : null, 'menubar' : null, 'directories' : null, 'resizable' : null, 'scrollbars' : null }; }); }