Firefox also supports the innertext method of IE.
CopyCode The Code is 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 method to htmlelement in Mozilla) copy Code the code is as follows: try {
// create span element so that htmlelement is accessible
document. createelement ('span ');
htmlelement. prototype. click = function () {
If (typeof this. onclick = 'function')
This. onclick ({type: 'click'});
};
}< br> catch (E) {
// alert ('click Method for htmlelement couldn \'t be added');
}
Add an onclick event to htmlanchorelement
copy Code the code is as follows: Try {
// create a element so that htmlanchorelement is accessible
document. createelement ('A');
htmlelement. prototype. click = function () {
If (typeof this. onclick = 'function') {
If (this. onclick ({type: 'click'}) & this. href)
window. OPE N (this. href, this.tar get? This.tar get: '_ Self');
}< br> else if (this. href)
window. Open (this. href, this.tar get? This.tar get: '_ Self');
};
}< br> catch (E) {
// alert ('click Method for htmlanchorelement couldn \'t be added');
}
trace the Enter key event copy Code the code is as follows: function capturekeys (EVT) {
var keycode = EVT. keycode? EVT. keycode:
EVT. charcode? EVT. charcode: EVT. which;
If (keycode = 13) {
// cancel key:
If (EVT. preventdefault) {
EVT. preventdefault ();
}< br> var DQ = getcookie ('default-engine ');
If (DQ = NULL) DQ = "baidu_txt ";
submit_query (DQ);
return false;
}< br> return true;
}