// Small debugging issues on Firefox. Use of alert ();
Alert (); when there is no parameter in it, it will not run in Firefox, ie can.
Alert (''); executed only when Firefox has parameters. Pay special attention to this when debugging Firefox.
Bytes -----------------------------------------------------------------------------------------------------
1) event
Event. srcelement can be seen literally with the following keywords: event, the source means: the source of the current event,
We can call various attributes like document. getelementbyid,
Some people often ask how to use event. srcelement in Firefox, which is described in detail here:
In ie, the event object has the srcelement attribute, but does not have the target attribute. In Firefox, the event object has the target attribute, but does not have the srcelement attribute. However, they play a similar role, namely:
Event. srcelement under event.tar get = IE in Firefox
Solution: Use OBJ (OBJ = event. srcelement? Event. srcelement: event.targettoken used to replace event.tar get under firefox.
Http://www.firefox.hk
You can directly use the event object in IE, but not in ff. One of the solutions is as follows:
VaR theevent = Window. Event | arguments. callee. Caller. Arguments [0];
The second is to pass the event as a parameter:
Function XXX (e) {var theevent = Window. Event | E ;}
Srcelement and target
In IE, srcelement indicates the source of the event, for example, which button triggers the onclick event, and FF indicates the target.
VaR theevent = Window. Event | arguments. callee. Caller. Arguments [0];
VaR srcelement = theevent. srcelement;
If (! Srcelement ){
Srcelement = theevent.tar get;
}
Example:
Document. onclick = function (e ){
VaR theevent = Window. Event | E;
VaR srcelement = theevent. srcelement;
If (! Srcelement ){
Srcelement = theevent.tar get;
}
}
Function clickaction (){
VaR theevent = Window. Event | arguments. callee. Caller. Arguments [0];
VaR srcelement = theevent. srcelement;
If (! Srcelement ){
Srcelement = theevent.tar get;
}
// Do something;
}
Function clickaction (e ){
VaR theevent = Window. Event | E;
VaR srcelement = theevent. srcelement;
If (! Srcelement ){
Srcelement = theevent.tar get;
}
// Do something;
}
Event. keycode and event. Which
FF does not support window. event. keycode, instead of event. Which.
Column:
// Mask the tab key on the webpageCode
Document. onkeydown = function (e ){
VaR theevent = Window. Event | E;
VaR code = theevent. keycode | theevent. Which;
If (code = 9 ){
Return false;
}
}
2) document. All
Document. all is a collection of elements obtained by IE before the DOM standard is established. According to ID and name, a large collection of elements is determined by the DOM standard, getelementbyid gradually replaces the all object set, but Firefox uses document to be compatible with some files written for IE. the All script is mandatory. The document is added. if (document. all), and the use of document is blocked in doctype with the correct XHTML. all
3) event
Window. Event // IE
E // FF
E = Window. Event | E
3) Determine whether the page is loaded
IE: Document. onreadystatechange = function () {document. readystate = "complete "}
FF: Document. addeventlistener ("domcontentloaded", handle, false)
When an event is triggered, a function must be executed. attachevent can be used in IE, and addeventlistener must be used in ff.
Attachevent () has two parameters: the first is the event name, and the second is the function to be executed;
Addeventlistener () has three parameters. The first one is the event name, but unlike the IE event, the event does not contain "ON". For example, "onsubmit" should be "Submit" here ", the second is the function to be executed, and the third parameter is a Boolean value;
Source: webmaster-http://www.master8.net/data/2007/0620/article_10074.htm
4) set the left and top positions of containers.
IE: you do not need to add unit PX.
FF: the Unit PX must be added.
Bytes -------------------------------------------------------------------------------------------
// A method used to input integers.
Isint: <input type = "text" onkeyup = "isint (event);">
// Integer type
Function isint (e ){
// Keycode: IE supported, and which: FF supported.
VaR theevent = Window. Event | E;
VaR code = theevent. keycode | theevent. Which;
If (Code <48 | code> 57 ){
// Alert (CODE); // srcelement: IE supported, target: FF supported
Var val = E. srcelement? E. srcelement: e.tar get;
Val. value = Val. value. substring (0, Val. value. Length-1 );
}
}
Bytes ---------------------------------------------------------------------------------------------
// "|": It can also be used to assign values. In ff, There is no window. Event, and an object must be assigned. Isint (event );
Function isint (e ){
VaR oevent = E | window. event; // used to judge whether it is IE or FF and assign it to the object.
VaR otarget = oevent.tar GET | oevent. srcelement; // The object used to retrieve IE or ff.
}
This article is reproduced from: http://www.cnblogs.com/yexinw/archive/2011/08/12/2136282.html
// Small debugging issues on Firefox. Use of alert ();
Alert (); when there is no parameter in it, it will not run in Firefox, ie can.
Alert (''); executed only when Firefox has parameters. Pay special attention to this when debugging Firefox.
Bytes -----------------------------------------------------------------------------------------------------
1) event
Event. srcelement can be seen literally with the following keywords: event, the source means: the source of the current event,
We can call various attributes like document. getelementbyid,
Some people often ask how to use event. srcelement in Firefox, which is described in detail here:
In ie, the event object has the srcelement attribute, but does not have the target attribute. In Firefox, the event object has the target attribute, but does not have the srcelement attribute. However, they play a similar role, namely:
Event. srcelement under event.tar get = IE in Firefox
Solution: Use OBJ (OBJ = event. srcelement? Event. srcelement: event.targettoken used to replace event.tar get under firefox.
Http://www.firefox.hk
You can directly use the event object in IE, but not in ff. One of the solutions is as follows:
VaR theevent = Window. Event | arguments. callee. Caller. Arguments [0];
The second is to pass the event as a parameter:
Function XXX (e) {var theevent = Window. Event | E ;}
Srcelement and target
In IE, srcelement indicates the source of the event, for example, which button triggers the onclick event, and FF indicates the target.
VaR theevent = Window. Event | arguments. callee. Caller. Arguments [0];
VaR srcelement = theevent. srcelement;
If (! Srcelement ){
Srcelement = theevent.tar get;
}
Example:
Document. onclick = function (e ){
VaR theevent = Window. Event | E;
VaR srcelement = theevent. srcelement;
If (! Srcelement ){
Srcelement = theevent.tar get;
}
}
Function clickaction (){
VaR theevent = Window. Event | arguments. callee. Caller. Arguments [0];
VaR srcelement = theevent. srcelement;
If (! Srcelement ){
Srcelement = theevent.tar get;
}
// Do something;
}
Function clickaction (e ){
VaR theevent = Window. Event | E;
VaR srcelement = theevent. srcelement;
If (! Srcelement ){
Srcelement = theevent.tar get;
}
// Do something;
}
Event. keycode and event. Which
FF does not support window. event. keycode, instead of event. Which.
Column:
// Code for blocking the tab key on the webpage
Document. onkeydown = function (e ){
VaR theevent = Window. Event | E;
VaR code = theevent. keycode | theevent. Which;
If (code = 9 ){
Return false;
}
}
2) document. All
Document. all is a collection of elements obtained by IE before the DOM standard is established. According to ID and name, a large collection of elements is determined by the DOM standard, getelementbyid gradually replaces the all object set, but Firefox uses document to be compatible with some files written for IE. the All script is mandatory. The document is added. if (document. all), and the use of document is blocked in doctype with the correct XHTML. all
3) event
Window. Event // IE
E // FF
E = Window. Event | E
3) Determine whether the page is loaded
IE: Document. onreadystatechange = function () {document. readystate = "complete "}
FF: Document. addeventlistener ("domcontentloaded", handle, false)
When an event is triggered, a function must be executed. attachevent can be used in IE, and addeventlistener must be used in ff.
Attachevent () has two parameters: the first is the event name, and the second is the function to be executed;
Addeventlistener () has three parameters. The first one is the event name, but unlike the IE event, the event does not contain "ON". For example, "onsubmit" should be "Submit" here ", the second is the function to be executed, and the third parameter is a Boolean value;
Source: webmaster-http://www.master8.net/data/2007/0620/article_10074.htm
4) set the left and top positions of containers.
IE: you do not need to add unit PX.
FF: the Unit PX must be added.
Bytes -------------------------------------------------------------------------------------------
// A method used to input integers.
Isint: <input type = "text" onkeyup = "isint (event);">
// Integer type
Function isint (e ){
// Keycode: IE supported, and which: FF supported.
VaR theevent = Window. Event | E;
VaR code = theevent. keycode | theevent. Which;
If (Code <48 | code> 57 ){
// Alert (CODE); // srcelement: IE supported, target: FF supported
Var val = E. srcelement? E. srcelement: e.tar get;
Val. value = Val. value. substring (0, Val. value. Length-1 );
}
}
Bytes ---------------------------------------------------------------------------------------------
// "|": It can also be used to assign values. In ff, There is no window. Event, and an object must be assigned. Isint (event );
Function isint (e ){
VaR oevent = E | window. event; // used to judge whether it is IE or FF and assign it to the object.
VaR otarget = oevent.tar GET | oevent. srcelement; // The object used to retrieve IE or ff.
}
This article is reproduced from: http://www.cnblogs.com/yexinw/archive/2011/08/12/2136282.html