<script src="../js/jquery.min.js"></script>
<script type="text/javascript">
jQuery(window).load(function () {
//jQuery(function($){
//按比例放缩图片
$("img").each(function(){
if(this.id=='srcImg'){
var image=this;
if(image.width>400||image.height>400){
var w;
var h;
if(image.width>image.height){
w=400;
h=400/image.width*image.height;
}else{
w=400/image.height*image.width;
h=400;
}
$('#srcImg').width(w);
$('#srcImg').height(h);
//$('#srcImg').css('visibility','visible');
}
}
});
});
</javascript>
<img alt="原图" id="srcImg" src="<%=path %>" >
在使用 //jQuery(function($){});加载图片时在火狐浏览器中会有显示原图片大小的bug,改用jQuery(window).load(function () { });可以解决该问题。