©Copyright 蕃薯耀 2020-01-07 https://www.cnblogs.com/fanshuyao/ (如果你覺得文章對你有幫助,歡迎捐贈,^_^,謝謝!) ©Copyright 蕃薯耀 2020-01-07 https://www.cnblogs.com/fanshuyao/ ...
================================
©Copyright 蕃薯耀 2020-01-07
https://www.cnblogs.com/fanshuyao/
var isIE=!!window.ActiveXObject; //是否IE瀏覽器 var isIE6=isIE&&!window.XMLHttpRequest; //是否IE6瀏覽器 var isIE7=isIE&&!isIE6&&!isIE8; //是否IE7瀏覽器 var isIE8=isIE&&!!document.documentMode; //是否IE8瀏覽器 var availheight = screen.availHeight; //預設高度為屏幕的高度 if(isIE8){ availheight= screen.height; } //IE11升級彈出視窗小 if (!!window.ActiveXObject || "ActiveXObject" in window){ availheight= screen.height; } /********************************************************************************** *函數名稱: 打開新視窗 *功能說明: 通過傳遞參數打開一個定製的新視窗, *參數說明: surl: URL地址 windowName 彈出視窗的名字(不是文件名),非必須,可用空''代替; iheight 視窗高度; iwidth 視窗寬度; itop 視窗距離屏幕上方的象素值; ileft 視窗距離屏幕左側的象素值; stoolbar 是否顯示工具欄,yes為顯示; smenubar 是否顯示菜單欄,yes為顯示; sscrollbars 是否顯示滾動欄,yes為顯示; sresizable 是否允許改變視窗大小,yes為允許; slocation 是否顯示地址欄,yes為顯示; sstatus 是否顯示狀態欄內的信息(通常是文件已經打開),yes為顯示; ***********************************************************************************/ function openCustomWindow(surl,windowName,itop,ileft,iwidth,iheight,stoolbar,smenubar, sscrollbars,sresizable,slocation, sstatus) { window.open (surl, windowName, 'height='+iheight+', width='+iwidth+', top='+itop+', left='+ileft+', toolbar='+stoolbar+', menubar='+smenubar+', scrollbars='+sscrollbars+',resizable='+sresizable+',location='+slocation+', status='+sstatus) } /** * 打開一個居中的視窗 * @param pageUrl url鏈接 * @param innerWidth 寬度,不帶px,小於0表示百分比 * @param innerHeight 高度,不帶px,小於0表示百分比 */ function openWindowCenter(pageUrl, innerWidth, innerHeight){ var screenWidth = screen.availWidth; var screenHeight = screen.availHeight; var width = screenWidth; var height = screenHeight; if(innerWidth < 1){ width = screenWidth * innerWidth; screenWidth = (screen.availWidth - width)/2; }else{ width = innerWidth; screenWidth = (screen.availWidth - innerWidth)/2; } if(innerHeight < 1){ height = screenHeight * innerHeight; screenHeight = (screen.availHeight - height)/2; }else{ height = innerHeight; screenHeight = (screen.availHeight - innerHeight)/2; } window.open(pageUrl, "", "left=" + screenWidth + ",top=" + screenHeight +",width=" + width + ",height=" + height + ",resizable=no,scrollbars=no,status=no,toolbar=no,menubar=no,location=no"); }; /** * 打開一個居中的視窗,可有滾動條 * @param pageUrl url鏈接 * @param innerWidth 長度,不帶px * @param innerHeight 寬度,不帶px */ function openWindowScroll(pageUrl, innerWidth, innerHeight){ var screenWidth = (screen.availWidth - innerWidth)/2; var screenHeight = (screen.availHeight - innerHeight)/2; window.open(pageUrl, "", "left=" + screenWidth + ",top=" + screenHeight +",width=" + innerWidth + ",height=" + innerHeight + ",resizable=no,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no"); }; /** * 打開一個居中的視窗,可變大小 * @param pageUrl url鏈接 * @param innerWidth 長度,不帶px * @param innerHeight 寬度,不帶px */ function openWindowResizable(pageUrl, innerWidth, innerHeight){ var screenWidth = (screen.availWidth - innerWidth)/2; var screenHeight = (screen.availHeight - innerHeight)/2; window.open(pageUrl, "", "left=" + screenWidth + ",top=" + screenHeight +",width=" + innerWidth + ",height=" + innerHeight + ",resizable=yes,scrollbars=no,status=no,toolbar=no,menubar=no,location=no"); };
(如果你覺得文章對你有幫助,歡迎捐贈,^_^,謝謝!)
================================
©Copyright 蕃薯耀 2020-01-07
https://www.cnblogs.com/fanshuyao/