I'm trying to rewrite a plugin that I wrote a while back since the code has been lost. Basically this plugin makes it easy to have a link open in a popup window I'm having a problem preventing a new window from opening when using javascript:void(0). Below is the code.
jQuery.fn.PopUpWindow = function(){ return this.each(function(index){ var setting, href, parameters, newwindow, a, b, c, $this; $this = jQuery(this); a = $this.attr("rel").split(","); href = $this.attr("href"); settings = { height:400, // height of window width:400, // width of window toolbar:false, // should we show the toolbar {true,false} scrollbars:0 // should we show the scollbars {0,1} }; // overrides the settings with parameter passed in using the rel tag. for(var i=0; i < a.length; i++) { b = a[i].split(":"); if(typeof settings[b[0]] != "undefined" && b.length == 2) { settings[b[0]] = b[1]; } } parameters = "height=" + settings.height + ",width=" + settings.width + ",toolbar=" + settings.toolbar + ",scrollbars=" + settings.scrollbars; /* there seems to be a problem with this code. For some reason browsers don't like * the fact that I'm setting the href to javascript:void(0) here. */ $this.attr("href", "javascript:void(0);"); $this.bind("click", function(){ var name = "PopUpWindow" + index; return !window.open(href, name, parameters).focus(); }); }); }; An example of a link: [a href="/popups/jurisdictions.cfm" class="popup" rel="height:600,width:310"]click here[/a] NOTE: I'm using brackets to get Nabble to display the code. So the basic problem is that when you click on the link it will open 2 windows instead of just the pop up. Any ideas on how to fix this? -- View this message in context: http://www.nabble.com/.attr%28%22href%22%2C-%22javascript%3Avoid%280%29-%22%29-not-working-tf3310158.html#a9207761 Sent from the JQuery mailing list archive at Nabble.com. _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/