js彈出的對話窗口永遠(yuǎn)保持居中顯示
更新時(shí)間:2012年12月15日 17:30:24 作者:
本文將介紹js彈出的對話窗口永遠(yuǎn)保持居中顯示實(shí)現(xiàn)方法,需要了解的朋友可以參考下
復(fù)制代碼 代碼如下:
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
<style type="text/css">
.Div_Scroll {
position:fixed;
margin:-10px;
visibility:hidden;
background-color:#808080;
opacity:0.6;
z-index:99;
}
.Div_Scroll_Content {
position:relative;
margin-top:20%;
width:inherit;
height:inherit;
}
.Div_AlertWindow {
margin:auto;
width:200px;
height:100px;
background-color:lightblue;
border:5px solid #f00;
}
</style>
<script type="text/javascript">
window.onload = function () {
var alertWindow = $("alertParent");
alertWindow.style.width = window.screen.availWidth + "px";
alertWindow.style.height = window.screen.height + "px";
$("Sure").onclick = function () {
alertWindow.style.visibility = "hidden";
}
}
function ShowAlert() {
var alertWindow = $("alertParent");
alertWindow.style.visibility = "visible";
}
$ = function (id) {
return document.getElementById(id);
}
</script>
</head>
<body>
<div id="alertParent" class="Div_Scroll">
<div class="Div_Scroll_Content">
<div id="AlertWindow" class="Div_AlertWindow">
<input type="button" id="Sure" value="close alert Dialog..." />
</div>
</div>
</div>
<div style="height:1300px; padding-top:200px;" >
<input id="alertButton" type="button" onclick="ShowAlert();" value="Show alert Dialog..."/>
</div>
</body>
</html>
添加遮罩層
相關(guān)文章
JavaScript 參數(shù)中的數(shù)組展開 [譯]
有些時(shí)候,我們需要把一個(gè)數(shù)組展開成多個(gè)元素,然后把這些元素作為函數(shù)調(diào)用的參數(shù).JavaScript中可以使用Function.prototype.apply來實(shí)現(xiàn)這種展開操作,但它不能被應(yīng)用在執(zhí)行構(gòu)造函數(shù)的情況下.本文解釋了什么是展開操作以及如何在使用new運(yùn)算符的同時(shí)進(jìn)行展開操作2012-09-09Bootstrap每天必學(xué)之附加導(dǎo)航(Affix)插件
Bootstrap每天必學(xué)之附加導(dǎo)航(Affix)插件,附加導(dǎo)航即粘貼在屏幕某處實(shí)現(xiàn)錨點(diǎn)功能,感興趣的小伙伴們可以參考一下2016-04-04JS獲取一個(gè)表單字段中多條數(shù)據(jù)并轉(zhuǎn)化為json格式
這篇文章主要介紹了JS獲取一個(gè)表單字段中多條數(shù)據(jù)并轉(zhuǎn)化為json格式的相關(guān)資料,需要的朋友可以參考下2017-10-10bootstrap fileinput 上傳插件的基礎(chǔ)使用
這篇文章主要介紹了bootstrap fileinput 上傳插件基礎(chǔ)使用,重點(diǎn)是把界面做得更加友好,更好的增加用戶體驗(yàn)。對bootstrap fileinput知識感興趣的朋友通過本文一起學(xué)習(xí)吧2017-02-02JavaScript注冊監(jiān)聽事件和清除監(jiān)聽事件方式詳解
js中事件監(jiān)聽就是利用addEventListener來綁定一個(gè)事件,這個(gè)用法在jquery中非常常用并且簡單,但在原生js中比較復(fù)雜,下面這篇文章主要給大家介紹了關(guān)于JavaScript注冊監(jiān)聽事件和清除監(jiān)聽事件方式的相關(guān)資料,需要的朋友可以參考下2023-05-05