您的位置:首页 > Web前端 > JavaScript

javascript弹出图片,背景变暗

2009-11-16 14:09 211 查看
 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;" />
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息