Compatibility between IE and Firefox

Source: Internet
Author: User

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

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.