史上最牛X最简洁的Javascript图片缩放代码
源码:
function resize(img, width, height) {
(img.width > img.height)
? ((img.height = Math.min(height, width * img.height/img.width)) || (img.width = Math.min(width, img.width)))
: ((img.width = Math.min(width, height * img.width/img.height)) || (img.height = Math.min(height, img.height)));
}
稍微压缩一下:
function resize1(i,w,h){var a=i.width;var b=i.height;a>b?((i.height=Math.min(h,w*b/a))||(i.width=Math.min(w,a))):((i.width=Math.min(w,h*a/b))||(i.height = Math.min(h,b)));}
相关文档:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>drag类</title ......
http://www.cnblogs.com/yzx99/archive/2008/08/08/1263416.html
单引号,双引号,javascript,HTML,转义字符
在一个网页中的按钮,写onclick事件的处理代码,不小心写成如下:
<input value="Test" type="button" onclick="alert(""OK"");" />
IE提示出错后,再漫不经心地改为:
<input value="Test" type="bu ......
<script type="text/javascript">
function getFileSize(filePath) {
var image=new Image();
image.dynsrc=filePath;
alert(image.fileSize);
}
</script> &nbs ......
东西很简单,只是自己记性不好,经常忘记一些关键字
所以发了点时间整理了一下
/*------------------------------------------------------
*作者:xieyu @ 2007-08-14
*语言:JavaScript
*说明:select元素javascript常用操作
* 1.判断是否存在指定value的Item
* 2.加入一 ......