javascript弹出图片,背景变暗

来源:互联网 发布:mac软件怎么退出 编辑:程序博客网 时间:2024/04/29 13:28

 JS文件:
<script language="javascript" type="text/javascript">
function zC(url){
var picurl="../"+url;
 var cWidth,cHeight;
 cWidth = screen.width;
 cHeight = screen.height;
 var cObj = document.createElement("div");
 cObj.setAttribute("id","cdiv");
 cObj.style.position = "absolute";
 cObj.style.top = 0;
 cObj.style.left = 0;
 cObj.style.backgroundColor = "#CCCCCC";
 cObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
 cObj.style.width = cWidth +"px";
 cObj.style.height = cHeight + "px";
 cObj.style.zIndex = "1000";
 document.body.appendChild(cObj);
 var iObj = document.createElement("img");
 iObj.setAttribute("id","cimg");
 iObj.style.position = "absolute";
 iObj.style.top = "50%";
 iObj.style.left = "50%";
 iObj.style.width = "500px";
 iObj.style.height ="400px";
 iObj.style.marginLeft = "-220px" ;
 iObj.style.marginTop = -155+"px";
 iObj.style.textAlign = "center";
 iObj.src = picurl;
 iObj.style.zIndex = "1001";
 iObj.style.cursor = "hand";
 iObj.onclick = function(){
  document.body.removeChild(iObj);
  document.body.removeChild(cObj);
 }
 document.body.appendChild(iObj);
}

</script>

 

服务器控件:

   <img src='<%#Eval("picUrl") %>' onclick='zC("<%#Eval("picUrl") %>")' style="cursor:hand; width:20PX; height:20px;" />