javascript之弹出窗口居中的代码
javascript弹出窗口居中代码
下面给两个弹出屏幕居中窗口的例子
代码如下:
window.open()方式 function ShowDialog(url) { var iWidth=300; //窗口宽度 var iHeight=200;//窗口高度 var iTop=(window.screen.height-iHeight)/2; var iLeft=(window.screen.width-iWidth)/2; window.open(url,"Detail","Scrollbars=no,Toolbar=no,Location=no,Direction=no,Resizeable=no, Width="+iWidth+" ,Height="+iHeight+",top="+iTop+",left="+iLeft); }
window.showModalDialog方式
代码如下:
function ShowDialog(url) { var iWidth=300; //窗口宽度 var iHeight=200;//窗口高度 var iTop=(window.screen.height-iHeight)/2; var iLeft=(window.screen.width-iWidth)/2; window.showModalDialog(url,window,"dialogHeight: "+iHeight+"px; dialogWidth: "+iWidth+"px; dialogTop: "+iTop+"; dialogLeft: "+iLeft+"; resizable: no; status: no;scroll:no"); }
注意这里的第二个参数,window
用户必须在这个弹出式窗体中输入信息后才能访问其他的窗体是模态窗体就是用第二个方法就好了
javascript弹出窗口居中四:
代码如下:
function selectCustomer(){ var iTop = (window.screen.availHeight-30-500)/2; var iLeft = (window.screen.availWidth-10-750)/2; window.open("../customer/creditApprManage.do?method=toGetCustomer", "searchCorp", "height=500,width=750,top="+iTop+",left="+iLeft+",toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no" ); }
说明:500和750是硬编码,可以通过参数传入。
相关推荐
zrtlin 2020-11-09
xuebingnan 2020-11-05
wikiwater 2020-10-27
heheeheh 2020-10-19
Crazyshark 2020-09-15
softwear 2020-08-21
ZGCdemo 2020-08-16
jczwilliam 2020-08-16
littleFatty 2020-08-16
idning 2020-08-03
jinxiutong 2020-07-26
lanzhusiyu 2020-07-19
Skyline 2020-07-04
xiaofanguan 2020-06-25
Aveiox 2020-06-23
dragonzht 2020-06-17