易截截图软件、单文件、免安装、纯绿色、仅160KB

史上最牛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)));}


相关文档:

JavaScript CSS Style属性参考

CSS语法 (不区分大小写)   JavaScript语法 (区分大小写)
border   border
border-bottom   borderBottom
border-bottom-color   borderBottomColor
border-bottom-style   borderBottomStyle
border-bottom-width   borderBottomWidth
border-color   borderColor
border-left   borderLeft ......

javascript 内存泄露工具使用

javascript内存泄露的问题一直以来都不受到大家的重视,原因是对用户的影响没有太实际的表现,或许近几年内存发展迅速。脚本内存再泄露也不会有太大影响。
当然作为前端开发的同学们,就不能有这样的侥幸心理。出现memory leaks很大程度上是因为程序的不成熟和编码不太规范造成的。不过,这里就不说如何出现问题的,对问题 ......

javascript CDATA

CDATA 内部的所有东西都会被解析器忽略。
假如文本中包含了大量的 "<" 和 "&" 字符 - 就像编程代码中经常出现的情况一样 - 那么这个 XML 元素就可以被定义为一个 CDATA 部分。
CDATA 区段开始于 "<![CDATA[",结束于 "]]>":
<script type="text/javascri ......

javascript 中的innerHTML的用法

javascript中innerHtml用法
2009-04-21 22:52
<html>
<head>
<script language="javascript">
function Test(){
       var str="";
       str+="Hello,";
       str+="This ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号