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;" />
<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;" />
相关文章推荐
- 【Javascript】IE8兼容 背景图片与a标签的onclick事件
- javascript随机显示背景图片的方法
- 自己写的mootools弹出框效果 没用css和背景图片
- JS实现:点击后,图片弹出放大,背景变黑的效果
- 关于javascript控制系统弹出下载提示 用以下载图片
- javascript添加背景图片
- js javascript 设置页面背景色,设置背景图片
- JavaScript 网页背景图片随机化
- js javascript图层的弹出 背景变灰 和js图层的移动 及相关资料
- 解决键盘弹出时,webview被挤压导致背景图片被挤压出空白
- Javascript弹出页面根据图片来缩放页面大小
- JavaScript实现背景变暗,弹出提示层(类似关机效果)
- ASP.NET&Javascript实现半透明背景&模式弹出个性化页面实例
- JavaScript 实现背景图片随机浮动
- JavaScript 点击页面上的按纽,弹出层,背景变灰
- JavaScript 鼠标事件改变背景图片
- JavaScript实现文本框中默认显示背景图片在获得焦点后消失的方法
- 如何解决在ASP.NET中应用JavaScript的 alert 函数时弹出的窗口背景全部为白色的问题
- [Javascript] 解决 IE6 中 png 图片背景不支持透明效果的问题