<img>标签替换src后的图像尺寸问题 弄个隐藏域,保存上次修改的width和height 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以用var img = new Image();img.src="xxx";这样的方式预加载也可以在生成旁边图片名称的时候 得出其对应图片的width,height属性 点击更改的时候将右边的width,height也改了 在加载另一幅图片前把width、height复位一下不行吗? 可以先将原来的<img>去掉,再新建一个img标签,设置src后加进去。 保存之前的尺寸肯定不行,预加载这里不太好改可能还得动结构。通过URL不知道能不能直接读出原始文件的尺寸 <SCRIPT LANGUAGE="JavaScript">function fun(obj){var img = new Image();img.src=obj.src;obj.width=img.width;obj.height=img.height;}</SCRIPT><img src="" onload="fun(this)">这样呢 使用id 搭配innerHtml 每次重写<img> 标签。 <html><head><script>var imgs=["http://avatar.profile.csdn.net/2/E/9/2_Teng_s2000.jpg","http://zi.csdn.net/475×60.gif","http://www.csdn.net/Images/logo_csdn.gif"]var _picIndex = 0;window.onload=function(){ $("im").src=imgs[_picIndex];}function nextPic(){ _picIndex++; if(_picIndex>imgs.length-1) { _picIndex = 0; } $("im").style["width"]=null; $("im").style["height"]=null; $("im").src=imgs[_picIndex];}function zoonOut(){ var w = $("im").offsetWidth*1.2; var h = $("im").offsetWidth*1.2; $("im").style.width=w; $("im").style.hight=h;}function $(id){ return document.getElementById(id);}</script><body><img id="im" style="border:dashed 1px #ccc"><br><input type="button" value="+" onclick="zoonOut()"><input type="button" value="Next" onclick="nextPic()"></div></body></html> align 图片显示 事件的传递问题。 这个查询功能怎么实现.特急 把方向右键转换成Tab键 ,怎样把方向左键转换成Shift+Tab 急 表单提交,select多选时,怎么处理?谢谢! 判断手机端还是PC端访问 怎么用JS控制RADIO的初始值?少见! 问个错误处理? 我在一个链接的点击事件中设置了cookie值,但是在页面跳转后的onload()事件中读取的时候经常是旧的值 求一个可以拖动的框的js代码? 怎么在客户端机器上得到服务器当前时间? [服务器不受控制]
var img = new Image();
img.src="xxx";
这样的方式预加载也可以在生成旁边图片名称的时候 得出其对应图片的width,height属性
点击更改的时候将右边的width,height也改了
通过URL不知道能不能直接读出原始文件的尺寸
<SCRIPT LANGUAGE="JavaScript">
function fun(obj)
{
var img = new Image();
img.src=obj.src;
obj.width=img.width;
obj.height=img.height;
}
</SCRIPT>
<img src="" onload="fun(this)">这样呢
<head>
<script>
var imgs=[
"http://avatar.profile.csdn.net/2/E/9/2_Teng_s2000.jpg",
"http://zi.csdn.net/475×60.gif",
"http://www.csdn.net/Images/logo_csdn.gif"
]
var _picIndex = 0;
window.onload=function(){
$("im").src=imgs[_picIndex];
}function nextPic()
{
_picIndex++;
if(_picIndex>imgs.length-1)
{
_picIndex = 0;
}
$("im").style["width"]=null;
$("im").style["height"]=null;
$("im").src=imgs[_picIndex];
}function zoonOut()
{
var w = $("im").offsetWidth*1.2;
var h = $("im").offsetWidth*1.2;
$("im").style.width=w;
$("im").style.hight=h;
}
function $(id)
{
return document.getElementById(id);
}
</script>
<body>
<img id="im" style="border:dashed 1px #ccc">
<br>
<input type="button" value="+" onclick="zoonOut()">
<input type="button" value="Next" onclick="nextPic()">
</div>
</body>
</html>