
<script type="text/javascript">
//首先要对HTMLElement进行类型检查,因为即使在支持HTMLElement的浏览器中,类型却是有差别的,在Chrome,Opera中HTMLElement的类型为function,此时就不能用它来判断了
var isDOM = ( typeof HTMLElement === 'object' ) ?
function(obj){
return obj instanceof HTMLElement;
} :
function(obj){
return obj && typeof obj === 'object' && obj.nodeType === 1 && typeof obj.nodeName === 'string';
}
</script>