国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

js寫一個彈出層并鎖屏效果實現代碼

2024-05-06 14:20:42
字體:
來源:轉載
供稿:網友
代碼如下:
<!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=gb2312" />
<title>一個彈出層并鎖屏效果</title>
</head>
<body>
<div>
<div>
<p>測試</p><p>測試</p><p>測試</p><p>測試</p><p>測試</p><p>測試</p><p>測試</p>
<p>測試</p><p>測試</p><p>測試</p><p>測試</p><p>測試</p><p>測試</p><p>測試</p>
<input type="button" value="點擊這里" onClick="sAlert('測試彈出層并鎖屏效果');" />
</div>
</div>
<script language="javascript">
function sAlert(str)
{
var msgw,msgh,bordercolor;
msgw=400;//提示窗口的寬度
msgh=100;//提示窗口的高度
titleheight=25 //提示窗口標題高度
bordercolor="#336699";//提示窗口的邊框顏色
titlecolor="#99CCFF";//提示窗口的標題顏色
var sWidth,sHeight;
sWidth=document.body.offsetWidth;//獲取窗口寬度
sHeight=screen.height;//獲取屏幕高度
var bgObj=document.createElement("div");//關鍵在這里,原理:在body中創建一個div,并將其寬度與高度設置為覆蓋整個窗體,如此一來就無法對其它窗口時行操作
bgObj.setAttribute('id','bgDiv');
bgObj.style.position="absolute";
bgObj.style.top="0";
bgObj.style.background="#777";
bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
bgObj.style.opacity="0.6";
bgObj.style.left="0";
bgObj.style.width=sWidth + "px";
bgObj.style.height=sHeight + "px";
bgObj.style.zIndex = "10000";
document.body.appendChild(bgObj);//設置完此div后將其顯示出來
var msgObj=document.createElement('div');//創建一個消息窗口
msgObj.setAttribute("id","msgDiv");
msgObj.setAttribute("align","center");
msgObj.style.background="white";
msgObj.style.border="1px solid " + bordercolor;
msgObj.style.position = "absolute";
msgObj.style.left = "50%";
msgObj.style.top = "50%";
msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
msgObj.style.marginLeft = "-225px" ;
msgObj.style.marginTop = -75+document.documentElement.scrollTop+"px";
msgObj.style.width = msgw+"px";
msgObj.style.height = msgh+"px";
msgObj.style.textAlign = "center";
msgObj.style.lineHeight ="25px";
msgObj.style.zIndex = "10001";
var title=document.createElement("h4"); //創建一個標題,以備放置在消息層
title.setAttribute("id","msgTitle");
title.setAttribute("align","right");
title.style.margin="0";
title.style.padding="3px";
title.style.background=bordercolor;
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 东平县| 文化| 汪清县| 剑川县| 隆尧县| 富川| 高青县| 新巴尔虎左旗| 长宁县| 宣威市| 大邑县| 原平市| 湘乡市| 张掖市| 庆云县| 叶城县| 固阳县| 白玉县| 安丘市| 新泰市| 都江堰市| 土默特左旗| 宁海县| 德格县| 浮梁县| 文水县| 乌恰县| 阿荣旗| 洪江市| 新竹市| 济南市| 建昌县| 南川市| 宜州市| 河津市| 家居| 锦屏县| 丹东市| 全南县| 忻城县| 德格县|