回 帖 发 新 帖 刷新版面

主题:双击放大缩小图片问题!

双击放大缩小问题!

谁能指点一下,双击就可以放大图片和缩小图片呀。双击一次放大一定比例,再双击再放大一定比例!或缩小一定比例!

回复列表 (共1个回复)

沙发


<input type="button" value="缩小" onclick="small1()"> 
<input type="button" value="放大" onclick="big1()"> 
 
<script> 
function small(){ 
var height1=images0.height 
var width1=images0.width 
images0.height=height1/1.5 
images0.width=width1/1.5 

 
function big(){ 
var height1=images0.height 
var width1=images0.width 
images0.height=height1*1.5 
images0.width=width1*1.5 

 
 
function small1(){ 
var height1=images1.height 
var width1=images1.width 
images1.height=height1/1.5 
images1.width=width1/1.5 

 
function big1(){ 
var height1=images1.height 
var width1=images1.width 
images1.height=height1*1.5 
images1.width=width1*1.5 

 
</script> 
这是一个代码


<input type=button value='慢慢变大' onclick=max()> 
<input type=button value='慢慢变小' onclick=min()>
<img id=MainImg src=images/k0212.gif>
<script>var i=0//变大function max(){MImg=MainImg.style.pixelWidth+=i++MainImg.style.pixelHeight=MImg*aaaif(i<20)setTimeout('max()',100)}//变小function min(){MImg=MainImg.style.pixelWidth-=i--MainImg.style.pixelHeight=MImg*aaaif(i>0)setTimeout('min()',100)}function init(){aaa=MainImg.height/MainImg.widthMainImg.style.pixelWidth=0MainImg.style.pixelHeight=0}onload=init
</script>
这也是一个代码,你自己根据他们做吧!你要的功能JS很容易就能实现

我来回复

您尚未登录,请登录后再回复。点此登录或注册