设为首页
加入收藏
帮助中心
首页 | 红盾通告 | 信息中心 | ASP技术 | 数据库 | 网页设计 | 网管专栏 | OICQ攻略 | 墨客频道 | 网站运营 |
当前位置:首页 >> 网页设计 >> Javascript >> 正文
最新信息
·Javascript处理数字的几个…
·判断当前网页是否为本站页…
·鼠标指上图片替换后出现下…
·逍遥狼无图片智能圆角
·javascript获取当前网页文…
·用javascript获得地址栏参…
·JavaScript常用判断函数
·双击鼠标滚动屏幕的代码
·web应用漏洞扫描工具Jikto…
·常备JS操作
资料搜索
热点信息
·js获取图片尺寸
·怎么让弹出窗口最大化
·web应用漏洞扫描工具Jikto…
·判断radio多个单选按纽中是…
·如何用文字做一个只刷新验…
·防止F5刷新执行onunload事…
·Javascript获取IE浏览器窗…
·关闭IE时调用onbeforeunlo…
·js表单提交验证
·javascript获取当前网页文…
推荐信息
·显示日期方式
·添加到收藏夹
·终极应用--弹出的窗口之Co…
·防止被人frame
·web应用漏洞扫描工具Jikto…
·JavaScript常用的一些验证…
·关闭IE时调用onbeforeunlo…
·js表单提交验证
·自己综合其他资料写的一套…
·window.open具体参数


Google
 
自由控制显示图片大小
〖编辑:Cloudy | 浏览:人次〗

要完成此效果需要两个步骤

第一步:把如下代码加入到<head>区域中

<style>
 .divstyle{position:absolute; width="0";height:"0"}
</style>
<script>
<!--
function showimg(form)
{
adres = form.image_file.value;
index = adres.indexOf(".gif");
index = index + adres.indexOf(".jpg");
index = index + adres.indexOf(".bmp");
if (form.image_file.value == "")
  {alert("错误,未发现任何图片!");}
else
  {if (index == -3){alert("错误的图片格式");
    form.width.value=0;
    form.height.value=0;}
  else
    {
    var img_obj = new Image();
    img_obj = form.image_file.value;
    document.changing.src = img_obj;
    document.changing2.src= img_obj;
    document.changing.width = document.changing2.width;
    document.changing.height = document.changing2.height;
    set();
}
  }
}
fast = 0;
change = 0;
function upw(){
  document.image.width.value=parseInt(document.image.width.value)+1;
  resize();}
function over_upw(){upw();
  change = 1;
  changetime = setTimeout("fast_upw()","600");}
function fast_upw(){clearTimeout(changetime);
  upw();
  fast = setTimeout("fast_upw()","100");}
function clt(){
if (change == 1){clearTimeout(changetime);}
clearTimeout(fast);
change = 0;
}
function resize()  {document.changing.height = document.image.height.value;
  document.changing.width = document.image.width.value;}
function downw(){document.image.width.value=parseInt(document.image.width.value)-1;
  resize();}
function over_downw(){downw();
  change = 1;
  changetime = setTimeout("fast_downw()","600");}
function fast_downw(){clearTimeout(changetime);
  downw();
  fast = setTimeout("fast_downw()","100");}
function uph(){document.image.height.value=parseInt(document.image.height.value)+1;
 resize();}
function over_downh(){downh();
  change = 1;
  changetime = setTimeout("fast_downh()","600");}
function fast_downh(){clearTimeout(changetime);
  downh();
  fast = setTimeout("fast_downh()","100");}
function over_uph(){uph();
  change = 1;
  changetime = setTimeout("fast_uph()","600");}
function fast_uph(){clearTimeout(changetime);
  uph();
  fast = setTimeout("fast_uph()","100");}
function downh(){document.image.height.value=parseInt(document.image.height.value)-1;
  resize();}
function set(){
  document.image.width.value=document.changing.width;
  document.image.height.value=document.changing.height;}
-->
</script>


第二步:把如下代码加入到<body>区域中

<center>
<form name="image">
<input type="file" name="image_file"><br><br>
<input type="button" name="show" value="Show image" onclick="showimg(this.form)">
<br><br>
宽   高
<br><img src="../ts/pic/up.gif" onmousedown="over_upw()" onmouseup="clt()">
<img src="../ts/pic/down.gif" onmousedown="over_downw()" onmouseup="clt()">
<input type="text" name="width" size="4" readonly>
<input type="text" name="height" size="4" readonly>
<img src="../ts/pic/up.gif" onmousedown="over_uph()" onmouseup="clt()" >
<img src="../ts/pic/down.gif" onmousedown="over_downh()" onmouseup="clt()">
<br><br>
<table border ="2">
<tr><td>
<img src="http://jojoo.net/www.jojoo.net/LOGO.gif" name="changing">
</td></tr></table>
</form>
<div STYLE="left:-5000 px;top:0" class="divstyle">
<P ><img src="http://jojoo.net/www.jojoo.net/LOGO.gif" name="changing2"></p>
</div>
</center>


录入时间:2006-06-20 12:32:45 [打印本页] [关闭窗口] [返回顶部]
特别声明: 本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。

Copyright © 2006-2014 0733168.Com Inc All Rights Reserved
关于我们 | 广告合作 | 联系我们 | 法律声明 | 友情链接 | 意见反馈
本站所收录信息、社区话题、及本站所做之广告均属其个人行为,与本站立场无关
湘ICP备06008436号