1 2 /** 3 * 4 * Javascript open window 5 * http://www.webtoolkit.info/ 6 * 7 **/ 8 9 function openWindow(anchor, options) { 10 11 var args = ''; 12 13 if (typeof(options) == 'undefined') { var options = new Object(); } 14 if (typeof(options.name) == 'undefined') { options.name = 'win' + Math.round(Math.random()*100000); } 15 16 if (typeof(options.height) != 'undefined' && typeof(options.fullscreen) == 'undefined') { 17 args += "height=" + options.height + ","; 18 } 19 20 if (typeof(options.width) != 'undefined' && typeof(options.fullscreen) == 'undefined') { 21 args += "width=" + options.width + ","; 22 } 23 24 if (typeof(options.fullscreen) != 'undefined') { 25 args += "width=" + screen.availWidth + ","; 26 args += "height=" + screen.availHeight + ","; 27 } 28 29 if (typeof(options.center) == 'undefined') { 30 options.x = 0; 31 options.y = 0; 32 args += "screenx=" + options.x + ","; 33 args += "screeny=" + options.y + ","; 34 args += "left=" + options.x + ","; 35 args += "top=" + options.y + ","; 36 } 37 38 if (typeof(options.center) != 'undefined' && typeof(options.fullscreen) == 'undefined') { 39 options.y=Math.floor((screen.availHeight-(options.height || screen.height))/2)-(screen.height-screen.availHeight); 40 options.x=Math.floor((screen.availWidth-(options.width || screen.width))/2)-(screen.width-screen.availWidth); 41 args += "screenx=" + options.x + ","; 42 args += "screeny=" + options.y + ","; 43 args += "left=" + options.x + ","; 44 args += "top=" + options.y + ","; 45 } 46 47 if (typeof(options.scrollbars) != 'undefined') { args += "scrollbars=1,"; } 48 if (typeof(options.menubar) != 'undefined') { args += "menubar=1,"; } 49 if (typeof(options.locationbar) != 'undefined') { args += "location=1,"; } 50 if (typeof(options.resizable) != 'undefined') { args += "resizable=1,"; } 51 52 var win = window.open(anchor, options.name, args); 53 return false; 54 55 }
You need to create an account or log in to post comments to this site.