为什么要将图片拉扯得不象样,
能不能考虑:只定义宽度,让它按比例显示:
<img src="../My%20Documents/My%20Pictures/tuzehui.jpg" width=300 >
(注意:用width=300,不是用style="width:300")
能不能考虑:只定义宽度,让它按比例显示:
<img src="../My%20Documents/My%20Pictures/tuzehui.jpg" width=300 >
(注意:用width=300,不是用style="width:300")
最好是去测试一下不同的IE版本是否支持这样做。先隐藏再显示,跳来跳去的效果可能会弱一点
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language=javascript>function DrawImage(ImgD){
alert();
var image=new Image();
image.src=ImgD.src;
if(image.width>image.height*3){
if(image.width>300){
ImgD.width=300;
}
}
else{
if(image.height>=100){
ImgD.height=100;
}
}
ImgD.style.display="";
}</script><title>New Page 2</title>
</head><body ><img src="../My%20Documents/My%20Pictures/tuzehui.jpg" name="boss" onload="DrawImage(this)" style="display:none"></body></html>
是用来观看如果网速很慢时的效果,
不是错误
去掉就是
<img src="images/aaa.jpg" name="boss" onload="javascript:DrawImage(this);">改为:
<img src="images/aaa.jpg" name="boss" onload="javascript:DrawImage(this);" width="0">这样load的时候就不会显示,更不会出现什么原始大小了。^_^
-->>
<img src="images/aaa.jpg" name="boss" onload="javascript:DrawImage(this);" width="1">
0对于width来说,是无效的,相当于没有赋。
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 1</title>
<script language="javascript">
var flag=false;
function DrawImage(ImgD){
var image=new Image();
image.src=ImgD.src;
if(image.width>0 && image.height>0){
flag=true;
if(image.width/image.height>=500/400){
if(image.width>100){
ImgD.width=100;
ImgD.height=(image.height*100)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
else{
if(image.height>100){
ImgD.height=100;
ImgD.width=(image.width*200)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
}
}
</script>
</head><body><table border="0" width="227" height="96" align="left">
<tr>
<td height="50" width="300">
<img border="0" src="images/2.jpg" onload="javascript:DrawImage(this)" width="0"> </td>
</tr>
<tr>
<td height="50" width="300">
<a href="new_page_0.htm">
<img border="0" src="images/3.jpg" onload="javascript:DrawImage(this)" width="0"></a></td>
</tr>
</table></body></html>2)---------------------------------------------------------------------------------
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 1</title>
<script language="javascript">
function DrawImage(ImgD){
var image=new Image();
image.src=ImgD.src;
if(image.width>image.height*3){
if(image.width>300){
ImgD.width=300;
}
}
else{
if(image.height>=100){
ImgD.height=100;
}
}
}
</script>
</head><body><table border="0" width="227" height="96" align="left">
<tr>
<td height="100" width="300">
<table border="0" width="263" height="320">
<tr>
<td height="316" width="263">
<img border="0" src="images/2.jpg" onload="javascript:DrawImage(this)" width="0"></td>
</tr>
</table>
<a href="new_page_1.htm">
<img border="0" src="images/2.jpg" onload="javascript:DrawImage(this)" width="0"></a></td>
</tr>
</table></body></html>
的确是有效果