喜悦国际村 
» 游客:  注册 | 登录 | 搜索 | 统计 | 帮助

RSS 订阅当前论坛  

喜悦证交所已经关闭

上一主题 下一主题
     
标题: [问题] js能如此处理图片吗?  
 
仪琳
中级会员
Rank: 3Rank: 3
一般会员



UID 21651
精华 0
积分 224
帖子 162
金钱 224 喜悦币
威望 0
人脉 0
阅读权限 30
注册 2003-7-14
状态 离线
js能如此处理图片吗?

我希望下面的代码能够做到:
1、如果图片宽度大于680,则自动将图片的宽度设为680。小于680,则显示原尺寸。
2、同时放大的宽度极限也是680。也就是最大放大宽度不能超过680。如果原图小于680,最大放大宽度不能超过原图宽度。

<script language="JavaScript">
var zoomLevel = 0;
var currentWidth = 0;
var currentHeight = 0;
var originalWidth = 0;
var originalHeight = 0;
function initial(){
    currentWidth = document.testImage.width;
    currentHeight = document.testImage.height;
    originalWidth = currentWidth;
    originalHeight = currentHeight;
    update();
}
function zoomIn(){
    document.testImage.width = currentWidth*2;
    document.testImage.height = currentHeight*2;
    zoomLevel = zoomLevel + 1;
    update();
}
function zoomOut(){
    document.testImage.width = currentWidth/2;
    document.testImage.height = currentHeight/2;
    zoomLevel = zoomLevel - 1;
    update();
}

</script>


<input type="button" value="放大" onclick="zoomIn()">
<input type="button" value="缩小" onclick="zoomOut()">
<img src=<%= request("testImage")%>  name="testImage" id="testImage" >






http://www.zhuatu.com   
2007-5-6 01:10 PM#1
查看资料  发短消息  顶部
 
sanders_yao
版主
Rank: 7Rank: 7Rank: 7
or2 =333


UID 30286
精华 0
积分 11786
帖子 4970
金钱 11783 喜悦币
威望 0
人脉 3
阅读权限 100
注册 2004-7-23
来自 北京 菜户营
状态 离线
[推荐阅读] 一个有关MYSQL查询的问题
应该可以控制图片宽度 虽然自己没做过



最近写的一些代码都会在以下地址发布,有兴趣的来批:
http://www.phpx.com/happy/thread-131368-1-1.html
2007-5-7 09:10 PM#2
查看资料  Blog  发短消息  顶部
     


  可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题 | 开通个人空间  


 




Powered by Discuz! 6.1.0  © 2001-2010 Comsenz Inc.
Processed in 0.021865 second(s), 6 queries

(冀ICP备05009913号) 管理员:sadly 邮箱/MSN: sadly@phpx.com QQ:824008(长隐) 清除 Cookies - - Archiver - WAP