图片自动缩小的JS代码
来源:互联网 发布:WebView打开打开软件 编辑:程序博客网 时间:2024/05/16 13:05
<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>= 180/110){
if(image.width>180){
ImgD.width=180;
ImgD.height=(image.height*110)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
/*ImgD.alt="bigpic" */
}
else{
if(image.height>110){
ImgD.height=110;
ImgD.width=(image.width*110)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
/*ImgD.alt="bigpic" */
}
}
}
<!--
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>= 180/110){
if(image.width>180){
ImgD.width=180;
ImgD.height=(image.height*110)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
/*ImgD.alt="bigpic" */
}
else{
if(image.height>110){
ImgD.height=110;
ImgD.width=(image.width*110)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
/*ImgD.alt="bigpic" */
}
}
}
//-->
</script>
图片使用的地方:
<img src="图片" border=0 width="180" height="110" onload="JavaScriptrawImage(this);">
width="180" height="110" 注意这里最好限定,如果不限定加载图时会成原大,然后再缩小,这个过程如果图大了很难看的.这里是宽度和高度,在前面的JS里改,这里也作相应的改.
- 图片自动缩小的JS代码
- 图片自动缩小的代码
- js让图片自动按比例缩小代码
- 图片自动缩小的js代码,用以防止图片撑破页面
- 网页图片自动缩小代码
- 指定区域的图片自动按比例缩小的js代码(防止页面被图片撑破)
- 适合所有CMS的文章中图片自动缩小到特定尽寸的通用JS代码
- JS图片自动按比例缩小代码(防止页面被图片撑破)
- 图片被IE自动缩小的问题
- 图片被IE自动缩小的问题
- 让FCKeditor插入的图片自动缩小
- 自动生成图片缩略图的JS代码
- js+css图片自动等比例缩小且垂直居中
- js+css图片自动等比例缩小且垂直居中
- js+css图片自动等比例缩小且垂直居中
- 关于图片放大缩小的js
- js-图片的放大和缩小
- JS实现图片的放大和缩小
- 利用JS获取IE客户端IP及MAC的实现
- 如何计算 一个音视频文件 (.ts)文件 (包含pcr信息). 播放所使用的带宽
- 初装ORACLE 10G后EM登陆的典型问题
- 国外软件外包网分类
- java 面试中的一道编写一个截取字符串的函数
- 图片自动缩小的JS代码
- 取消插U盘时自动播放功能
- 编码问题
- 《Recommended C Style and Coding Standards》学习总结
- 二叉树的递归穿线实现
- 使用struts时,中文问题
- JavaScript 中eval()函数
- css 错误
- 堆和优先队列的实现