加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

html点击按钮弹出窗口背景灰掉,点击背景变白退出点击退出也可以

(2011-06-10 18:22:23)
标签:

杂谈

function showid(idname){
var isIE = (document.all) ? true : false;
var isIE6 = isIE && ([/MSIE (\d)\.0/i.exec(navigator.userAgent)][0][1] == 6);
var newbox=document.getElementByIdx_x(idname);
newbox.style.zIndex="9999";
newbox.style.display="block"
newbox.style.position = !isIE6 ? "fixed" : "absolute";
newbox.style.top =newbox.style.left = "50%";
newbox.style.marginTop = - newbox.offsetHeight / 2 + "px";
newbox.style.marginLeft = - newbox.offsetWidth / 2 + "px";
var layer=document.createElement_x("div");
layer.id="layer";
layer.style.width=layer.style.height="100%";
layer.style.position= !isIE6 ? "fixed" : "absolute";
layer.style.top=layer.style.left=0;
layer.style.backgroundColor="#000";
layer.style.zIndex="9998";
layer.style.opacity="0.6";
document.body.appendChild(layer);
function layer_iestyle(){
layer.style.width=Math.max(document.documentElement.scrollWidth, document.documentElement.clientWidth)+ "px";
layer.style.height= Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight) +"px";
}
function newbox_iestyle(){
newbox.style.marginTop = document.documentElement.scrollTop - newbox.offsetHeight / 2 + "px";
newbox.style.marginLeft = document.documentElement.scrollLeft - newbox.offsetWidth / 2 + "px";
}
if(isIE){layer.style.filter ="alpha(opacity=60)";}
if(isIE6){
layer_iestyle()
newbox_iestyle();
window.attachEvent("onscroll",function(){
newbox_iestyle();
})
window.attachEvent("onresize",layer_iestyle)
}
layer.onclick=function(){newbox.style.display="none";layer.style.display="none";document.body.removeChild(layer)}
}
function closelayer(){

 layer=document.getElementByIdx_x('layer'); 
 newbox=document.getElementByIdx_x('address-book');
 newbox.style.display="none"; 
 layer.style.display="none";document.body.removeChild(layer);
 }

 

上面是js,html是下面酱紫的

下面是隐藏部分

<div id="address-book" style="display:none;">Address Book<br />
 <div>Last Name:
  <input name="Input" id="s_lastName" onkeyup="searchAB()" />
  First Name:
  <input name="Input" id="s_firstName" onkeyup="searchAB()" />
  Phone:
  <input name="Input" id="s_phone" onkeyup="searchAB()" />
 </div>

  <div>
 <input name="button" type="button" onclick="addContacts()" value="Add Contacts" />
 <input name="button" type="button" onclick="closelayer()" value="Close" ; />
  </div>

</div>

0

阅读 收藏 喜欢 打印举报/Report
后一篇:2011年06月25日
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有