判断NaN | isNaN(x) |
停止页面的加载 | window.stop ? window.stop() : document.execCommand("Stop"); |
代替alert() | console.log(); |
获取浏览器的宽高 |
function winHeight(){return window.innerHeight || document.documentElement.clientHeight; } function winWidth(){ return window.innerWidth || document.documentElement.clientWidth;} |
获取浏览器滚动条的top |
function winScrolltop(){return document.documentElement.scrollTop || document.body.scrollTop;} |
禁止input缓存 |
autocomplete="off" |
图片加载函数 |
function imgload(url,callback){ |
cssText |
element.style.cssText |
DOMContentLoaded |
(function() { |
匿名函数写法 |
方法1: (function(){ })(); 方法2: ~function(){ }(); |
IE渲染模式强制调到最高 |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> |
判断一个DOM是否为另一个的子集 |
contains(); father.contains(child) |
手机站设置代码 |
<meta name="viewport" content="width=640;initial-scale=1;minimum-scale=0.5;maximum-scale=0.5;user-scalable=yes"/> |
屏蔽复制,屏蔽右键菜单 |
document.body.oncopy = function(){ return false}; document.oncontextmenu = function(){return false} |