Javascript compatibility with firefox _ javascript skills

Source: Internet
Author: User
In the morning, I did some tests. When I got the page to Firefox, there were a bunch of problems. The page layout was not mentioned. The Javascript code problem was a headache, for example:
1. document. all () does not work in FF. It must be changed to document. getElementById ();
2. obj. innerText = "XXX"; in FF, it seems that there are occasional problems. Change to obj. innerHTML = "XXX.
3. var olE = document. body. onload; the onload function for retrieving the body. IE No problem. FF no problem. Change it to window. onload. solution.
What is the difference between window. onload and body. onload? It will be available for Baidu.
4. in IE, The. event object has the x and y attributes. FF does not have. event. x. It should be the event. pageX in FF.
Solution:. mX = event. x? Event. x: event. pageX; then use mX instead of event. x.
5. the most hateful thing is that Ajax cannot be called synchronously in FF !!!
For example, xmlHttp. open ("get", "xxx. aspx? Id = xx ", true); // true indicates asynchronous
No problem in IE and FF. But xmlHttp. open ("get", "xxx. aspx? Id = xx ", false); no problem in IE. It won't work in FF !!
No solution has been found for this problem.
6. I want to eat. It's not over yet ..
-----------
5th solved.
This is the case when synchronous calls are performed.

The Code is as follows:


XmlHttp. open ("get", "xxx. aspx? Id = xx ", false );

Xmlhttp. send (null );

If (xmlhttp. readyState = 4 ){
If (xmlhttp. status = 200 ){
// Alert (xmlhttp. responseText );
} Else {
Alert ("the page you requested has an exception. ");
}
}

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.