javascript彈出一個(gè)層并增加一個(gè)覆蓋層
更新時(shí)間:2008年10月10日 23:14:41 作者:
彈出一個(gè)層的js代碼,比較不錯(cuò)
復(fù)制代碼 代碼如下:
<!--內(nèi)容層-->
<div id="ShopConfirmLayer" style="position:absolute;top:300px;left:100px;z-index:900;border:1px red solid;width:500px;display:none;">
<input name="button1" value="關(guān)閉" type="button" onclick="CloseShopConfirm()"/>
</div>
<!--覆蓋層-->
<div id="webBgLayer" style="position:absolute;top:0px;left:0px;z-index:899;background-color:#ccc;height:100%;width:100%;display:none;-moz-opacity:0.5;filter:alpha(opacity=50);"></div>
<script type="text/javascript">
function ShopConfirm(str){
var ShopConfirmLayer=document.getElementById("ShopConfirmLayer");
var webBgLayer=document.getElementById("webBgLayer");
ShopConfirmLayer.innerHTML=str;
ShopConfirmLayer.style.display="";
ShopConfirmLayer.style.left=parseInt((document.documentElement.scrollWidth-ShopConfirmLayer.offsetWidth)/2)+document.documentElement.scrollLeft+"px";
ShopConfirmLayer.style.top=Math.abs(parseInt((document.documentElement.clientHeight-ShopConfirmLayer.offsetHeight)/2))+document.documentElement.scrollTop+"px";
webBgLayer.style.display="";
webBgLayer.style.height=document.documentElement.scrollHeight+"px";
}
function CloseShopConfirm(){
var ShopConfirmLayer=document.getElementById("ShopConfirmLayer");
var webBgLayer=document.getElementById("webBgLayer");
ShopConfirmLayer.style.display="none";
webBgLayer.style.display="none";
}
</script>
注意上面的代碼頭部DTD應(yīng)該是這樣:
復(fù)制代碼 代碼如下:
<!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">
[Ctrl+A 全選 注:引入外部Js需再刷新一下頁(yè)面才能執(zhí)行]
相關(guān)文章
JS實(shí)現(xiàn)簡(jiǎn)單的圖書(shū)館享元模式實(shí)例
這篇文章主要介紹了JS實(shí)現(xiàn)簡(jiǎn)單的圖書(shū)館享元模式,以一個(gè)圖書(shū)館存書(shū)借書(shū)的例子分析了圖書(shū)館享元模式的實(shí)現(xiàn)技巧,需要的朋友可以參考下2015-06-06
前端date.locale?is?not?a?function錯(cuò)誤的簡(jiǎn)單解決辦法
這篇文章主要給大家介紹了關(guān)于前端date.locale?is?not?a?function錯(cuò)誤的簡(jiǎn)單解決辦法,文中通過(guò)圖文介紹的非常詳細(xì),需要的朋友可以參考下2023-09-09
javascript event在FF和IE的兼容傳參心得(絕對(duì)好用)
event在IE和FF不兼,下面為大家分享的是javascript event在FF和IE的兼容傳參心得,需要的朋友可以參考下2014-07-07
iframe父頁(yè)面獲取子頁(yè)面參數(shù)的方法
這篇文章主要介紹了iframe父頁(yè)面獲取子頁(yè)面參數(shù)的方法,需要的朋友可以參考下2014-02-02
移動(dòng)端刮刮樂(lè)的實(shí)現(xiàn)方式(js+HTML5)
本篇文章主要介紹了移動(dòng)端刮刮樂(lè)的實(shí)現(xiàn)方法以及實(shí)現(xiàn)代碼。具有很好的參考價(jià)值。下面跟著小編一起來(lái)看下吧2017-03-03
JS實(shí)現(xiàn)的一個(gè)簡(jiǎn)單的Autocomplete自動(dòng)完成例子
這篇文章主要介紹了JS實(shí)現(xiàn)的一個(gè)簡(jiǎn)單的Autocomplete自動(dòng)完成例子,需要的朋友可以參考下2014-04-04

