首頁  >  文章  >  web前端  >  js open() 與showModalDialog()方法使用介紹_javascript技巧

js open() 與showModalDialog()方法使用介紹_javascript技巧

WBOY
WBOY原創
2016-05-16 17:22:52779瀏覽

此方法可通用,項目開發中經常要用到:

複製代碼 代碼如下:

//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
; height2 = Height - 50;
if (document.all && window.print) {
return_Value = window.showModalDialog(url, win, "dialogLeft:" iLeft2 "px;logTop:" iTop2 "dialogLeft:" iLeft2 "px;logTop:" iTop2 "px; "
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");
}
}
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn