js open() 與showModalDialog()方法使用介紹
更新時間:2013年09月10日 17:49:38 作者:
項目開發(fā)中經(jīng)常要用到j(luò)s open() 與showModalDialog()方法,下面有個不錯的示例,喜歡的朋友可以研究下
此方法可通用,項目開發(fā)中經(jīng)常要用到:
//w:寬,h:高,url:地址,tag:標記
function showWin(w, h, url, tag) {
var t = (screen.height - h) / 2; //離頂部距離
var l = (screen.width - w) / 2; //離左邊距離
window.open(url, tag, "width=" + w + ",height=" + h + ",top=" + t + ",left=" + l + ",location=0");
}
//路徑地址,window對象,寬,高
function open_Dialog(url, win,Width, Height) {
var return_Value;
var iTop2 = (window.screen.availHeight - 20 - Height) / 2;
var iLeft2 = (window.screen.availWidth - 10 - Width) / 2;
var height2 = Height - 50;
if (document.all && window.print) {
return_Value = window.showModalDialog(url, win, "dialogLeft:" + iLeft2 + "px;dialogTop:" + iTop2 + "px;dialogWidth:" +
Width + "px;dialogHeight:" + Height + "px;center:yes;status:no;scroll:no;help:no;");
}
else {
window.open(url, win, "top=" + iTop2 + ",left=" + iLeft2 + ",width=" + Width + "px,height=" + height2 +
"px,resizable=0,scrollbars=0,location=0");
}
}
復(fù)制代碼 代碼如下:
//w:寬,h:高,url:地址,tag:標記
function showWin(w, h, url, tag) {
var t = (screen.height - h) / 2; //離頂部距離
var l = (screen.width - w) / 2; //離左邊距離
window.open(url, tag, "width=" + w + ",height=" + h + ",top=" + t + ",left=" + l + ",location=0");
}
//路徑地址,window對象,寬,高
function open_Dialog(url, win,Width, Height) {
var return_Value;
var iTop2 = (window.screen.availHeight - 20 - Height) / 2;
var iLeft2 = (window.screen.availWidth - 10 - Width) / 2;
var height2 = Height - 50;
if (document.all && window.print) {
return_Value = window.showModalDialog(url, win, "dialogLeft:" + iLeft2 + "px;dialogTop:" + iTop2 + "px;dialogWidth:" +
Width + "px;dialogHeight:" + Height + "px;center:yes;status:no;scroll:no;help:no;");
}
else {
window.open(url, win, "top=" + iTop2 + ",left=" + iLeft2 + ",width=" + Width + "px,height=" + height2 +
"px,resizable=0,scrollbars=0,location=0");
}
}
您可能感興趣的文章:
- JS對話框_JS模態(tài)對話框showModalDialog用法總結(jié)
- js showModalDialog參數(shù)的使用詳解
- js showModalDialog彈出窗口實例詳解
- js showModalDialog 彈出對話框的簡單實例(子窗體)
- JS中showModalDialog 的使用解析
- js實現(xiàn)window.open不被攔截的解決方法匯總
- js中window.open打開一個新的頁面
- js中用window.open()打開多個窗口的name問題
- js window.open彈出新的網(wǎng)頁窗口
- js中window.open()的所有參數(shù)詳細解析
- js的window.showModalDialog及window.open用法實例分析
相關(guān)文章
JavaScript+canvas實現(xiàn)五子棋游戲
這篇文章主要為大家詳細介紹了JavaScript+canvas實現(xiàn)五子棋游戲,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2022-05-05
javascript使用正則表達式實現(xiàn)注冊登入校驗
這篇文章主要為大家詳細介紹了javascript使用正則表達式實現(xiàn)注冊登入校驗,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2020-09-09
JS實現(xiàn)CheckBox復(fù)選框全選全不選功能
在網(wǎng)站的管理后臺應(yīng)用此功能居多,如一次性處理多個產(chǎn)品,或?qū)ξ恼碌膭h除對產(chǎn)品的下架等處理,一條一條的點顯然有一些麻煩,如果能每一行放一個checkbox,然后統(tǒng)一處理就好辦的多了,今天我就用簡單的篇幅來講解一下這個功能的實現(xiàn)原理和實現(xiàn)過程。2015-05-05
BootStrap 動態(tài)添加驗證項和取消驗證項的實現(xiàn)方法
這篇文章主要介紹了BootStrap 動態(tài)添加驗證項和取消驗證項的實現(xiàn)方法的相關(guān)資料,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2016-09-09

