js open() 與showModalDialog()方法使用介紹
更新時間:2013年09月10日 17:49:38 作者:
項目開發(fā)中經(jīng)常要用到j(luò)s open() 與showModalDialog()方法,下面有個不錯的示例,喜歡的朋友可以研究下
此方法可通用,項目開發(fā)中經(jīng)常要用到:
//w:寬,h:高,url:地址,tag:標(biāo)記
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:標(biāo)記
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實現(xiàn)Vue跨組件通信的方法詳解
這篇文章主要為大家詳細介紹了Vue的跨組件通信,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來幫助2022-03-03基于javascript實現(xiàn)的購物商城商品倒計時實例
本文主要介紹了基于javascript實現(xiàn)的購物商城商品倒計時實例,代碼詳細,可直接復(fù)制試試看效果。需要的朋友可以參考借鑒2016-12-12easyui combobox開啟搜索自動完成功能的實例代碼
下面小編就為大家?guī)硪黄猠asyui combobox開啟搜索自動完成功能的實例代碼。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-11-11探析瀏覽器執(zhí)行JavaScript腳本加載與代碼執(zhí)行順序
本文主要基于向HTML頁面引入JavaScript的幾種方式,分析HTML中JavaScript腳本的執(zhí)行順序問題,通過本文給大家分享瀏覽器執(zhí)行JavaScript腳本加載與代碼執(zhí)行順序,對瀏覽器執(zhí)行javascript及執(zhí)行順序相關(guān)知識感興趣的朋友一起學(xué)習(xí)吧2016-01-01JS不同運算符下隱式類型轉(zhuǎn)換的實現(xiàn)示例
隱式轉(zhuǎn)換就是自動轉(zhuǎn)換,通常發(fā)生在一些數(shù)學(xué)運算中,本文就來介紹一下JS不同運算符下隱式類型轉(zhuǎn)換的實現(xiàn)示例,具有一定的參考價值,感興趣的可以了解一下2023-12-12