怎么实现双击图片的时候放大
<script>
window.onload=function(){
var rt=new imgRound("imgContainer",150,100,300,80,230,0.01);
setInterval(function(){rt.roundMove()},20)
}
function imgRound(id,w,h,x,y,r,dv,rh,ah){
if (ah==undefined) ah=1;
if (rh==undefined) rh=50;
var dv=dv*ah; //旋转速度
var pi=3.1415926575;
var d=pi/2;
var pd=Math.asin(w/2/r);
var smove=true;
var imgArr=new Array();
var objectId=id;
var o=document.getElementById(objectId);
o.style.position="relative";
var arrimg=o.getElementsByTagName("img");
var pn=arrimg.length; //图片数量
var ed=pi*2/pn;
for (n=0;n<arrimg.length;n++){
var lk=arrimg[n].getAttribute("link");
if (lk!=null) arrimg[n].setAttribute("title",lk)
arrimg[n].onclick=function(){
if (this.getAttribute("link")!=null){
if (this.getAttribute("target")!="_blank") window.location=(this.getAttribute("link"))
else window.open(this.getAttribute("link"))
}
}
arrimg[n].onmouseout=function(){smove=true;}
arrimg[n].onmouseover=function(){smove=false;}
arrimg[n].style.position="absolute";
imgArr.push(arrimg[n]);
}
this.roundMove=function(){
for (n=0;n<=pn-1;n++){
var o=imgArr[n];
var ta=Math.sin(d+ed*n),strFilter;
if (ta<0) o.style.left=Math.cos(d+ed*n-pd)*r+x+"px";
else o.style.left=Math.cos(d+ed*n+pd)*r+x+"px";
o.style.top=ta*rh+rh+y+"px";
var zoom=Math.abs(Math.sin((d+ed*n)/2+pi/4))*0.5+0.5;
o.style.width=Math.abs(Math.cos(d+ed*n+pd)-Math.cos(d+ed*n-pd))*zoom*r+"px";
o.style.height=zoom*h+"px";
if (ta<0) {ta=(ta+1)*80+20;o.style.zIndex=0;}
else {ta=100;o.style.zIndex=1}
if (o.style.zIndex<=0) strFilter="FlipH(enabled:true)"
else strFilter="FlipH(enabled:false)";
strFilter=strFilter+" alpha(opacity="+ta+")";
o.style.opacity=ta/100;
o.style.filter=strFilter;
}
if (smove) d=d+dv;
}
}
</script>
<div id="imgContainer" style="width:600px;height:300px;border:1px solid red">
<img src="http://www.idccyw.com/blueidea/images/s1.jpg"/>
<img src="http://www.idccyw.com/blueidea/images/s2.jpg"/>
<img src="http://www.idccyw.com/blueidea/images/s3.jpg"/>
<img src="http://www.idccyw.com/blueidea/images/s4.jpg" />
<img src="http://www.idccyw.com/blueidea/images/s5.jpg"/>
<img src="http://www.idccyw.com/blueidea/images/s1.jpg"/>
<img src="http://www.idccyw.com/blueidea/images/s2.jpg"/>
<img src="http://www.idccyw.com/blueidea/images/s3.jpg"/>
</div>
<script>
window.onload=function(){
var rt=new imgRound("imgContainer",150,100,300,80,230,0.01);
setInterval(function(){rt.roundMove()},20)
}
function imgRound(id,w,h,x,y,r,dv,rh,ah){
if (ah==undefined) ah=1;
if (rh==undefined) rh=50;
var dv=dv*ah; //旋转速度
var pi=3.1415926575;
var d=pi/2;
var pd=Math.asin(w/2/r);
var smove=true;
var imgArr=new Array();
var objectId=id;
var o=document.getElementById(objectId);
o.style.position="relative";
var arrimg=o.getElementsByTagName("img");
var pn=arrimg.length; //图片数量
var ed=pi*2/pn;
for (n=0;n<arrimg.length;n++){
var lk=arrimg[n].getAttribute("link");
if (lk!=null) arrimg[n].setAttribute("title",lk)
arrimg[n].onclick=function(){
if (this.getAttribute("link")!=null){
if (this.getAttribute("target")!="_blank") window.location=(this.getAttribute("link"))
else window.open(this.getAttribute("link"))
}
}
arrimg[n].onmouseout=function(){smove=true;}
arrimg[n].onmouseover=function(){smove=false;}
arrimg[n].style.position="absolute";
imgArr.push(arrimg[n]);
}
this.roundMove=function(){
for (n=0;n<=pn-1;n++){
var o=imgArr[n];
var ta=Math.sin(d+ed*n),strFilter;
if (ta<0) o.style.left=Math.cos(d+ed*n-pd)*r+x+"px";
else o.style.left=Math.cos(d+ed*n+pd)*r+x+"px";
o.style.top=ta*rh+rh+y+"px";
var zoom=Math.abs(Math.sin((d+ed*n)/2+pi/4))*0.5+0.5;
o.style.width=Math.abs(Math.cos(d+ed*n+pd)-Math.cos(d+ed*n-pd))*zoom*r+"px";
o.style.height=zoom*h+"px";
if (ta<0) {ta=(ta+1)*80+20;o.style.zIndex=0;}
else {ta=100;o.style.zIndex=1}
if (o.style.zIndex<=0) strFilter="FlipH(enabled:true)"
else strFilter="FlipH(enabled:false)";
strFilter=strFilter+" alpha(opacity="+ta+")";
o.style.opacity=ta/100;
o.style.filter=strFilter;
}
if (smove) d=d+dv;
}
}
</script>
<div id="imgContainer" style="width:600px;height:300px;border:1px solid red">
<img src="http://www.idccyw.com/blueidea/images/s1.jpg"/>
<img src="http://www.idccyw.com/blueidea/images/s2.jpg"/>
<img src="http://www.idccyw.com/blueidea/images/s3.jpg"/>
<img src="http://www.idccyw.com/blueidea/images/s4.jpg" />
<img src="http://www.idccyw.com/blueidea/images/s5.jpg"/>
<img src="http://www.idccyw.com/blueidea/images/s1.jpg"/>
<img src="http://www.idccyw.com/blueidea/images/s2.jpg"/>
<img src="http://www.idccyw.com/blueidea/images/s3.jpg"/>
</div>
解决方案 »
- JQuery中AJAX提交遇到了一个小问题
- 查询页面 点查询按钮 整个页面刷新 还是只刷新结果列表?
- ext.window()打开时,父窗口自动隐藏下拉框?这是为什么啊?
- JS图片大小设置(急)
- 为什么这段代码没法在浏览器中显示啊
- 如何在弹出的对话框访问父页面的函数
- dreamweaver浮动图标问题!急急急!
- 怎么样取<body><img src="..."></body><html></html>中body里面的值或者img相关的值啊?
- 一个简单的问题,请各位帮忙:如何把select中所选项的下标传递给onchange函数???
- 大家英文觉得水平怎样,可不可以达到随见随说的地步?
- 弱弱的问一下,为什么这个jQurey选择器在FF中没有效果?
- ie与Firefox间的关于session会话的兼容问题 有谁了解啊?
document.getElementById("img").width
document.getElementById("img").height
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>图片的放大和缩小</title>
<meta content="text/html; charset="GB2312" http-equiv="Content-Type" />
</head> <body>
<div>
<input type="button" value="打开" onclick="opened()"/> <input type="button" value="关闭" onclick="closeed()"/>
</div>
<div id="main">
<img src="12.jpg"/>
</div>
<script type="text/javascript">
var n=2;
var control=true;
var stop;
var div_main=document.getElementById("main");
var w=div_main.getElementsByTagName("img")[0].width;
//alert(w);
var h=div_main.getElementsByTagName("img")[0].height;
var x=div_main.getElementsByTagName("img")[0].left;
//alert(x);
var y=div_main.getElementsByTagName("img")[0].top;
function opened(){
if(control==true){
if(n>=20){
control=false;
window.clearTimeout(stop);
}else{
w+=5;
h+=5;
x+=5;
y+=5;
div_main.getElementsByTagName("img")[0].width=w;
div_main.getElementsByTagName("img")[0].height=h;
div_main.getElementsByTagName("img")[0].left=x;
div_main.getElementsByTagName("img")[0].top=y;
stop=setTimeout('opened()',100);
}
n++;
}
}
function closeed(){
if(control==false){
if(n<=0){
control=true;
window.clearTimeout(stop);
}else{
w-=5;
h-=5;
x-=5;
y-=5;
div_main.getElementsByTagName("img")[0].width=w;
div_main.getElementsByTagName("img")[0].height=h;
div_main.getElementsByTagName("img")[0].left=x;
div_main.getElementsByTagName("img")[0].top=y;
stop=setTimeout('closeed()',100);
}
n--;
}
}
</script>
</body>
</html>