-
<script type="text/javascript">
var Browser=new Object();
Browser.userAgent=window.navigator.userAgent.toLowerCase();
Browser.ie=/msie/.test(Browser.userAgent);
Browser.Moz=/gecko/.test(Browser.userAgent);
var PhotoShow={
url:"",
title:"",
alt:"",
objWidth:(window.innerWidth)?window.innerWidth:(document.documentElement&&document.documentElement.clientWidth)?document.documentElement.clientWidth:document.documentElement.offsetWidth,//获取窗体的可视区域的宽;
objHeight:(window.innerHeight)?window.innerHeight:(document.documentElement&&document.documentElement.clientHeight)?document.documentElement.clientHeight:document.documentElement.offsetHeight,//也可以加上document.documentElement.scrollHeight
init:function(){ //初始化,创建一个层宽度和高度为可视区域宽高
var creatediv=document.createElement("div");
creatediv.id="divscreen";
with(creatediv.style){
width=this.objWidth+"px";
height=this.objHeight+"px";
backgroundColor="#000";
position="absolute";
left="0px";
top="0px";
zIndex=80;
filter="alpha(opacity=20)";
opacity=0.2;
}
document.body.insertBefore(creatediv,document.body.childNodes[0]);
},
PhotoClick:function(){//调用后判断图片的加载情况
this.init();
var img=new Image();
if(Browser.ie){
img.onreadystatechange=function(){
if(img.readyState=="complete"||img.readyState=="loaded"){
PhotoShow.PhotoCallBack(img);
}
}
}else if(Browser.Moz){
img.onload=function(){
if(img.complete==true){
PhotoShow.PhotoCallBack(img);
}
}
}
img.src=this.url;
},
PhotoCallBack:function(obj){//再创建一个最上面的层
var imgwidth=obj.width;
var imgheight=obj.height;
var Itop=(this.objHeight-imgheight)/2-15;
var Ileft=(this.objWidth-imgwidth)/2;
var maindiv=document.createElement("div");
maindiv.id="maindiv";
with(maindiv.style){
width=imgwidth+"px";
height=imgheight+"px";
position="absolute";
left=right=Ileft+"px";
top=bottom=Itop+"px";
backgroundColor="skyblue";
border="1px solid #000";
padding="12px";
paddingBottom="20px";
zIndex=100;
}
maindiv.appendChild(obj);
var closediv=document.createElement("div");
closediv.width=imgwidth+20+"px";
with(closediv.style){
textAlign="center";
background="#fff";
fontSize="14px" ;
}
var Lhref=document.createElement("A");
Lhref.href="javascript:void(0)";
Lhref.appendChild(document.createTextNode("关 闭"));
Lhref.onclick=function(){
PhotoShow.PhotoRemove();
}
closediv.appendChild(Lhref);
if(Browser.ie){ //由于ff与ie在加载对象方面出现了差异所以..
obj.insertAdjacentElement("afterEnd",closediv);
}else if(Browser.Moz){
obj.parentNode.insertBefore(closediv,obj);
}
document.body.insertBefore(maindiv,document.body.childNodes[0]);
} ,
PhotoRemove:function(){ //移除对象
if(document.getElementById("maindiv")){
document.body.removeChild(document.getElementById("maindiv"));
}
if(document.getElementById("divscreen")){
document.body.removeChild(document.getElementById("divscreen"));
} return false;
}
}
</script>
<img src=http://www.xxx.com/1.jpg onclick="PhotoShow.url=http://www.xxx.com/1.jpg ;PhotoShow.PhotoClick();" width="200" height="200"/>var Browser=new Object();
Browser.userAgent=window.navigator.userAgent.toLowerCase();
Browser.ie=/msie/.test(Browser.userAgent);
Browser.Moz=/gecko/.test(Browser.userAgent);
var PhotoShow={
url:"",
title:"",
alt:"",
objWidth:(window.innerWidth)?window.innerWidth:(document.documentElement&&document.documentElement.clientWidth)?document.documentElement.clientWidth:document.documentElement.offsetWidth,//获取窗体的可视区域的宽;
objHeight:(window.innerHeight)?window.innerHeight:(document.documentElement&&document.documentElement.clientHeight)?document.documentElement.clientHeight:document.documentElement.offsetHeight,//也可以加上document.documentElement.scrollHeight
init:function(){ //初始化,创建一个层宽度和高度为可视区域宽高
var creatediv=document.createElement("div");
creatediv.id="divscreen";
with(creatediv.style){
width=this.objWidth+"px";
height=this.objHeight+"px";
backgroundColor="#000";
position="absolute";
left="0px";
top="0px";
zIndex=80;
filter="alpha(opacity=20)";
opacity=0.2;
}
document.body.insertBefore(creatediv,document.body.childNodes[0]);
},
PhotoClick:function(){//调用后判断图片的加载情况
this.init();
var img=new Image();
if(Browser.ie){
img.onreadystatechange=function(){
if(img.readyState=="complete"||img.readyState=="loaded"){
PhotoShow.PhotoCallBack(img);
}
}
}else if(Browser.Moz){
img.onload=function(){
if(img.complete==true){
PhotoShow.PhotoCallBack(img);
}
}
}
img.src=this.url;
},
PhotoCallBack:function(obj){//再创建一个最上面的层
var imgwidth=obj.width;
var imgheight=obj.height;
var Itop=(this.objHeight-imgheight)/2-15;
var Ileft=(this.objWidth-imgwidth)/2;
var maindiv=document.createElement("div");
maindiv.id="maindiv";
with(maindiv.style){
width=imgwidth+"px";
height=imgheight+"px";
position="absolute";
left=right=Ileft+"px";
top=bottom=Itop+"px";
backgroundColor="skyblue";
border="1px solid #000";
padding="12px";
paddingBottom="20px";
zIndex=100;
}
maindiv.appendChild(obj);
var closediv=document.createElement("div");
closediv.width=imgwidth+20+"px";
with(closediv.style){
textAlign="center";
background="#fff";
fontSize="14px" ;
}
var Lhref=document.createElement("A");
Lhref.href="javascript:void(0)";
Lhref.appendChild(document.createTextNode("关 闭"));
Lhref.onclick=function(){
PhotoShow.PhotoRemove();
}
closediv.appendChild(Lhref);
if(Browser.ie){ //由于ff与ie在加载对象方面出现了差异所以..
obj.insertAdjacentElement("afterEnd",closediv);
}else if(Browser.Moz){
obj.parentNode.insertBefore(closediv,obj);
}
document.body.insertBefore(maindiv,document.body.childNodes[0]);
} ,
PhotoRemove:function(){ //移除对象
if(document.getElementById("maindiv")){
document.body.removeChild(document.getElementById("maindiv"));
}
if(document.getElementById("divscreen")){
document.body.removeChild(document.getElementById("divscreen"));
} return false;
}
}
</script>

Js,Firmly put your fade
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· winform 绘制太阳,地球,月球 运作规律
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· AI 智能体引爆开源社区「GitHub 热点速览」
· Manus的开源复刻OpenManus初探
· 写一个简单的SQL生成工具