在window.onload事件处理就可以了。

解决方案 »

  1.   

    try
    -----------------------<div id="photo">
    <img src="aaa.gif">
    <img src="aaa.gif">
    <img src="aaa.gif">
    </div><script language="javascript">
    document.body.onload = function(){
    var photos = document.getElementById("photo").getElementsByTagName("img");
    for(var i=0;i<photos.length;i++){
    if(photos[i].width>135){
    photos[i].resized=true;
    photos[i].width=135;
    }
    if(photos[i].height>108){
    photos[i].resized=true;
    photos[i].height=108;
    }
    }
    }
    </script>
      

  2.   

    不让缓存的话,方法还不是一般的多:方法一
    <%
    response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
    //or response.setHeader("Cache-Control","no-store");//HTTP 1.1
    response.setHeader("Pragma","no-cache"); //HTTP 1.0
    response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
    %>方法二
    import java.text.SimpleDateFormat;
    import java.util.Date;SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy - HH:mm:ss z");
    response.setHeader("Expires", dateFormat.format(new Date())); 方法三
    <meta http-equiv='Expires' content='-10'>
    <meta http-equiv='Pragma' content='No-cache'>
    <meta http-equiv='Cache-Control', 'private'> 
      

  3.   

    其实原理都是设置页面header
    方法三最省事
      

  4.   

    可能是你的代码有问题
    <img  onload='if(this.width>560){this.height=(this.height/this.width)*560;this.width=560;'}>
      

  5.   

    上面那代码写错
    <img onload='if(this.width>560){this.height=(this.height/this.width)*560;this.width=560;}'>
      

  6.   

    谢谢各位,代码没有问题,因为它会执行,我问的关键是:有时候他不会执行onload里面的函数,我不想在加个js来控制。不知道哪位高人有什么技巧 让onload里面的语句一定执行!谢谢