忘了说了,是有的时候等于0,有的时候是正常的,我也是在不经意之时发现不对头,然后就加了
if(ImgD.height==0)
alert("高:"+image.height+" 宽:"+image.width+" 字:"+ImgD.vspace );
这个语句,结果发现,它让执行了。
if(ImgD.height==0)
alert("高:"+image.height+" 宽:"+image.width+" 字:"+ImgD.vspace );
这个语句,结果发现,它让执行了。
{
if(ImgD.width >0 && ImgD.height>0)
{
if(ImgD.width>ImgD.height)
{
var temp1=ImgD.width/160;
var temp2=ImgD.height;
ImgD.width=160;
ImgD.height=temp2/temp1;
ImgD.vspace=ImgD.vspace+(160-ImgD.height)/2;
}
else
{
var temp1=ImgD.height/160;
var temp2=ImgD.width;
ImgD.height=160;
ImgD.width=temp2/temp1;
}
ImgD.style.visibility="visible";
}
}还是不行啊,有的时候一个图片也显示不出来
{
if(ImgD.width >0 && ImgD.height>0)
{
if(ImgD.width>ImgD.height)
{
var temp1=ImgD.width/160;
var temp2=ImgD.height;
ImgD.width=160;
ImgD.height=temp2/temp1;
ImgD.vspace=ImgD.vspace+(160-ImgD.height)/2;
}
else
{
var temp1=ImgD.height/160;
var temp2=ImgD.width;
ImgD.height=160;
ImgD.width=temp2/temp1;
}
ImgD.style.visibility="visible";
}
else
{
alert(ImgD.width+","+ImgD.height);
}
}<td width="200" align="center"><img style="visibility:hidden" src=photo/13.jpg vspace=10 border=0 onload="adjustsize(this)"> <br>
“你直接把图片拉进一个ie窗口,右键看一下能否看到尺寸。”
这个什么意思,我一拉到IE窗口就显示出来了 没有尺寸啊
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>JK:支持民族工业,尽量少买X货</title>
<script>
function setMaxHeight(imgObj,maxHeight){
if(imgObj.offsetHeight>maxHeight) {
imgObj.height=maxHeight;
imgObj.removeAttribute('width');
}
}
</script>
</head>
<body>
<div style="font-size:10pt;">
注1:设定图片的最大宽度或高度,同时保证图片比例。 <br/> <br/>
注:本页面仅在IE6/FireFox1.5下测试过。其它浏览器或其它版本未经测试。<br/>
注-----:JK:<a href="mailTo:[email protected]?subject=About IMG">[email protected]</a><br/>
<hr/>
</div><IMG id="big_img2"
src="http://img.phoenixtv.com/tres/recommend/phoenixtv/scnews/070828-news-950x90.gif" width="200" onload="setMaxHeight(this,300);">
</body>
</html>
{
if(ImgD.offsetHeight>160)
{
ImgD.width=ImgD.width*160/ImgD.height;
ImgD.height=160;
imgObj.removeAttribute("width");
}
else
{
if(ImgD.height==0)
{
alert(ImgD.offsetHeight);
}
else
ImgD.vspace=(160-ImgD.height)/2;
}
}还是会弹出 0 的对话框,怎么才能保证adjustsize调用时图像已经加载上了,如果不能怎么来解决这个问题啊,如果问题低级还请大虾们见谅。
http://community.csdn.net/Expert/topic/5734/5734245.xml?temp=.8744165
http://community.csdn.net/Expert/topic/5736/5736479.xml?temp=.6601526