JS实现弹出居中的模式窗口示例
cherry 人气:0本文实例讲述了JS实现弹出居中的模式窗口。分享给大家供大家参考,具体如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>JS弹出窗口</title> </head> <body> <script src="jquery-1.7.2.min.js" type="text/javascript"></script> <script> function OpenDialog(url,w, h) { var iTop2 = (window.screen.availHeight - 20 - h) / 2; var iLeft2 = (window.screen.availWidth - 10 - w) / 2; var params = 'menubar:no;dialogHeight=' + h + 'px;dialogWidth=' + w + 'px;dialogLeft=' + iLeft2 + 'px;dialogTop=' + iTop2 + 'px;resizable=yes;scrollbars=0;resizeable=0;center=yes;location:no;status:no' var addDiv = $("<div id = 'tempDiv' style='left:0px;top:0px;position:absolute;width:100%;height:100%;background:rgba(0,0,0,0.4)!important;filter:alpha(opacity = 40);background:#000;z-index:1000;'></div>"); $(document.body).append(addDiv); //添加一个蒙板作背景 window.open(url, addDiv, params); } OpenDialog("//www.qb5200.com",300,300); </script> </body> </html>
希望本文所述对大家JavaScript程序设计有所帮助。
加载全部内容