js open() 與showModalDialog()方法使用介紹
更新時(shí)間:2013年09月10日 17:49:38 作者:
項(xiàng)目開發(fā)中經(jīng)常要用到j(luò)s open() 與showModalDialog()方法,下面有個(gè)不錯(cuò)的示例,喜歡的朋友可以研究下
此方法可通用,項(xiàng)目開發(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彈出窗口實(shí)例詳解
- js showModalDialog 彈出對話框的簡單實(shí)例(子窗體)
- JS中showModalDialog 的使用解析
- js實(shí)現(xiàn)window.open不被攔截的解決方法匯總
- js中window.open打開一個(gè)新的頁面
- js中用window.open()打開多個(gè)窗口的name問題
- js window.open彈出新的網(wǎng)頁窗口
- js中window.open()的所有參數(shù)詳細(xì)解析
- js的window.showModalDialog及window.open用法實(shí)例分析
相關(guān)文章
微信小程序中如何計(jì)算距離某個(gè)節(jié)日還有多少天
這篇文章主要給大家介紹了關(guān)于微信小程序中如何計(jì)算距離某個(gè)節(jié)日還有多少天的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用微信小程序具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-07-07
JavaScript+canvas實(shí)現(xiàn)五子棋游戲
這篇文章主要為大家詳細(xì)介紹了JavaScript+canvas實(shí)現(xiàn)五子棋游戲,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-05-05
javascript使用正則表達(dá)式實(shí)現(xiàn)注冊登入校驗(yàn)
這篇文章主要為大家詳細(xì)介紹了javascript使用正則表達(dá)式實(shí)現(xiàn)注冊登入校驗(yàn),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-09-09
JS實(shí)現(xiàn)CheckBox復(fù)選框全選全不選功能
在網(wǎng)站的管理后臺應(yīng)用此功能居多,如一次性處理多個(gè)產(chǎn)品,或?qū)ξ恼碌膭h除對產(chǎn)品的下架等處理,一條一條的點(diǎn)顯然有一些麻煩,如果能每一行放一個(gè)checkbox,然后統(tǒng)一處理就好辦的多了,今天我就用簡單的篇幅來講解一下這個(gè)功能的實(shí)現(xiàn)原理和實(shí)現(xiàn)過程。2015-05-05
p5.js實(shí)現(xiàn)故宮橘貓賞秋圖動(dòng)畫
這篇文章主要為大家詳細(xì)介紹了p5.js實(shí)現(xiàn)故宮橘貓賞秋圖動(dòng)畫,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-10-10
BootStrap 動(dòng)態(tài)添加驗(yàn)證項(xiàng)和取消驗(yàn)證項(xiàng)的實(shí)現(xiàn)方法
這篇文章主要介紹了BootStrap 動(dòng)態(tài)添加驗(yàn)證項(xiàng)和取消驗(yàn)證項(xiàng)的實(shí)現(xiàn)方法的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-09-09

