js简单的应用,请大家指点 在window.onload事件处理就可以了。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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> 不让缓存的话,方法还不是一般的多:方法一<%response.setHeader("Cache-Control","no-cache"); //HTTP 1.1//or response.setHeader("Cache-Control","no-store");//HTTP 1.1response.setHeader("Pragma","no-cache"); //HTTP 1.0response.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'> 其实原理都是设置页面header方法三最省事 可能是你的代码有问题<img onload='if(this.width>560){this.height=(this.height/this.width)*560;this.width=560;'}> 上面那代码写错<img onload='if(this.width>560){this.height=(this.height/this.width)*560;this.width=560;}'> 谢谢各位,代码没有问题,因为它会执行,我问的关键是:有时候他不会执行onload里面的函数,我不想在加个js来控制。不知道哪位高人有什么技巧 让onload里面的语句一定执行!谢谢 求问:图片效果 跪求一助:关于得到当前日期之后的两天 html奇怪的相对路径 大家帮帮忙 如何完全控制IE的打印? JS传递方法 关于点击列表调用iframe 接触Jquery不超过三个小时,关于导入JQ的问题 怎么得到动态添加的控件 各位高手有问题请教!!!帮我实现一下如下页面的功能。 $.get()总是执行不成功 高人看看应该怎么解决。。。 控制下拉框显示内容
-----------------------<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>
<%
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'>
方法三最省事
<img onload='if(this.width>560){this.height=(this.height/this.width)*560;this.width=560;'}>
<img onload='if(this.width>560){this.height=(this.height/this.width)*560;this.width=560;}'>