/* Popupwindow plugin for jQuery. Takes a link and will create a popupwindow based on the href of the link. You can over ride the default setting by passing your own settings using the REL attribute of the link. You can have different setting for each link if you'd like. To use just include the plugin in the HEAD section of the page AFTER calling jQuery. After that, use jQuery to find the links you want and pass any parameters you want 2007.03.14 - matt@atre.net - edited to allow use of default values, make alias settings cleaner and "do the right thing" is a user wants the window open in a tab. PopupWindow Example

Opens a popupwindow with default settings
jQuery Homepage

Open a popupwindow with each link having it's own settings
jQuery Homepage
jQuery Homepage

*/ jQuery.fn.popupwindow = function(){ return this.each(function(index){ var settings, parameters=[], mysettings, b, aliasSettings; // for overriding the default settings mysettings = (jQuery(this).attr("rel") || "").split(","); defaultSettings = settings = { height:'default', // sets the height in pixels of the window, default means use default value (same as current window). width:'default', // sets the width in pixels of the window, default means use default value (same as current window). menubar:0, // determines whether the menubar (includes the File, Edit, etc menus) is displayed {1 (YES) or 0 (NO)}. toolbar:0, // determines whether a toolbar (includes the forward and back buttons) is displayed {1 (YES) or 0 (NO)}. 'location': 0, directories: 0, scrollbars:1, // determines whether scrollbars appear on the window {1 (YES) or 0 (NO)}. status:1, // whether a status line appears at the bottom of the window {1 (YES) or 0 (NO)}. resize:1, // whether the window can be resized {1 (YES) or 0 (NO)}. left: 'default', // left position when the window appears. top: 'default', // top position when the window appears. inherit: 1 // inherit settings from the current browser window {1 (YES) or 0 (NO)}. }; aliasSettings = { left:'screenX', top:'screenY', resize:'resizable' }; // overrides the settings with parameter passed in using the rel tag. for(var i=0; i < mysettings.length; i++) { b = mysettings[i].split(":"); if(typeof settings[b[0]] != "undefined" && b.length == 2) settings[b[0]] = b[1]; } for (var k in settings) { if (settings[k] == 'default') continue; parameters[parameters.length] = [k,'=',settings[k]].join(''); if (aliasSettings[k]) parameters[parameters.length] = [aliasSettings[k],'=', settings[k]].join(''); } jQuery(this).bind("click", function(e){ var event = (!e) ? window.event : e; if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) return true; else { this.blur(); var name = "PopUpWindow" + index; if (settings['inherit']) { window.open(this.href, name).focus(); } else window.open(this.href, name, parameters.join(',')).focus(); return false; } }); }); };