javascript 经常会用到的东西
1.var target = event.target != null ? event.target : event.srcElement;
2.e = e||window.event
3.
var scrollTop = document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop;
var scrollLeft = document.body.scrollLeft ? document.body.scrollLeft : document.documentElement.scrollLeft;
4. clearSelection:function()
{
if(window.getSelection){//w3c
window.getSelection().removeAllRanges();
}else if(document.selection){
document.selection.empty();//IE
}
}
5. preventDefault:function(e)
{
e=dragObj.fixE(e);
if(e.preventDefaults)
e.preventDefaults();
else
e.returnValue=false;
},
6. cancelBubble:function(e)
{
e=dragObj.fixE(e);
if(e.stopPropagation)
{
e.stopPropagation();
}
else
{
e.cancelBubble=true;
}
},
js常用的东西
in a word ,ie is evil.