This section makes Firefox also support IE's InnerText method
Copy Code code as follows:
function Isie () {
if (Window.navigator.userAgent.toLowerCase (). IndexOf ("MSIE") >=1)
return true;
Else
return false;
}
if (!isie ()) {//firefox innertext define
htmlelement.prototype.__definegetter__ ("InnerText",
function () {
var anystring = "";
var ChildS = this.childnodes;
for (Var i=0 i <childS.length; i++) {
if (childs[i].nodetype==1)
AnyString + = childs[i].tagname== "BR"? ' \ n ': childs[i].innertext;
else if (childs[i].nodetype==3)
AnyString + = Childs[i].nodevalue;
}
return anystring;
}
);
htmlelement.prototype.__definesetter__ ("InnerText",
function (stext) {
This.textcontent=stext;
}
);
}
This section makes Firefox's htmlelement have the click Method(Add click HtmlElement in Mozilla)
Copy Code code as follows:
try {
Create span element So, HtmlElement is accessible
Document.createelement (' span ');
HTMLElement.prototype.click = function () {
if (typeof This.onclick = = ' function ')
This.onclick ({type: ' click '});
};
}
catch (e) {
Alert (' click Method for HtmlElement couldn\ ' t is added ');
}
Add onclick event to Htmlanchorelement
Copy Code code as follows:
try {
Create a element so this htmlanchorelement is accessible
Document.createelement (' a ');
HTMLElement.prototype.click = function () {
if (typeof This.onclick = = ' function ') {
if (This.onclick ({type: ' click '}) && This.href)
window.open (This.href, this.target this.target: ' _self ');
}
else if (this.href)
window.open (This.href, this.target this.target: ' _self ');
};
}
catch (e) {
Alert (' click Method for Htmlanchorelement couldn\ ' t is added ');
}
Tracking the ENTER key event
Copy Code code as follows:
function Capturekeys (evt) {
var keycode = evt.keycode? Evt.keycode:
Evt.charcode? Evt.charCode:evt.which;
if (keycode = =) {
//Cancel key:
if (evt.preventdefault) {
Evt.preventdefault ();
}
var dq = getcookie (' Default-engine ');
IF (dq = null) dq = "Baidu_txt";
Submit_query (DQ);
return false;
}
return true;
}