1. event. srcElement Problems
In IE, the event object has the srcElement attribute but does not have the target attribute;
In Firefox, the even object has the target attribute but does not have the srcElement attribute.
We can solve this problem as follows:
Webpage tutorial Network
Use obj (obj = event. srcElement? Event. srcElement: event.targettoken used to replace event.tar get under firefox.
2. The event mentioned above also has problems in the two browsers.
Window. event can only be run in IE, but not in Firefox,
This is because Firefox events can only be used when an event occurs.
Webpage tutorial Network
IE:
<Input type = "button" value = "Test Event" onclick = "test1 ()"/>
<Input type = "button" value = "Test Event compatibility" onclick = "test2 ()"/>
Webjx. Com
<Script language = "javascript">
Function test1 (){
Alert (window. event); // use window. event
}
Function test2 (evt ){
Evt = evt? Evt :( window. event? Window. event: null );
Alert (evt); // use the evt Parameter
}
</Script>
========================================================== =====
3. innerText works normally in IE, but innerText does not work in FireFox
Here is a solution
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> check the compatibility between IE and Firefox. </title>
</Head>
<Script language = "javascript">
Function testInnerText (){
If (navigator. appName. indexOf ("Explorer")>-1 ){
Document. getElementById ('element'). innerText = "my text ";
} Else {
Document. getElementById ('element'). textContent = "my text ";
}
}
</Script>
<Body>
<Input name = "Button" type = "button" value = "testInnerText" onclick = "javascript: testInnerText ()"/>
Webpage tutorial Network
<Div id = "element" style = "border: 1px solid # 0066CC; width: 100px; height: 50px"> </div>
</Body>
</Html> Webjx. Com