日期:2014-05-16 浏览次数:20366 次
document.body.detachEvent("onclick",onclickfunction); document.body.attachEvent("onclick",onclickfunction);
document.body.removeEventListener("click",onclickfunction, true); document.body.addEventListener("click",onclickfunction, true);
btn1Obj.attachEvent("onclick",method1); btn1Obj.attachEvent("onclick",method2); btn1Obj.attachEvent("onclick",method3);
btn1Obj.addEventListener("click",method1,false); btn1Obj.addEventListener("click",method2,false); btn1Obj.addEventListener("click",method3,false);
input.addEventListener("click",test,false); function test(e){ var e = window.event||e; var srcElement = e.srcElement || e.target; }
<input onclick="test(event)">
function test() { eval("window.a = '全局变量';"); eval("window.b = function(){alert('全局函数');}"); }
var isIE = document.all && window.external; function createXMLDoc(){ var xmlDoc; var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined'); var ie = (typeof window.ActiveXObject != 'undefined'); if (moz) { xmlDoc = document.implementation.createDocument("", "", null); } else if (ie) { xmlDoc = new ActiveXObject("MSXML2.DOMDocument.3.0"); xmlDoc.async = false; while (xmlDoc.readyState != 4) { }; } return xmlDoc; } function getElementValue(item){ if(isIE){ return item.text; }else{ return item.childNodes[0].nodeValue; } } if ( ! isIE){ XMLDocument.prototype.loadXML = function(xmlString) { var childNodes = this.childNodes; for (var i = childNodes.length - 1; i >= 0; i--) this.removeChild(childNodes[i]); var dp = new DOMParser(); var newDOM = dp.parseFromString(xmlString, "text/xml"); var newElt = this.importNode(newDOM.documentElement, true); this.appendChild(newElt); }; // check for XPath implementation if( document.implementation.hasFeature("XPath", "3.0") ) { // prototying the XMLDocument XMLDocument.prototype.selectNodes = function(cXPathString, xNode) { if( !xNode ) { xNode = this; } var oNSResolver = this.createNSResolver(this.documentElement) var aItems = this.evaluate(cXPathString, xNode, oNSResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null) var aResult = []; aResult.length = aItems.snapshotLength; for( var i = 0; i < aItems.snapshotLength; i++) {