Home >Web Front-end >JS Tutorial >Some issues with Javascript compatibility with firefox_javascript tips

Some issues with Javascript compatibility with firefox_javascript tips

WBOY
WBOYOriginal
2016-05-16 18:52:371057browse

For example:
1. document.all() does not work in FF. It must be changed to document.getElementById();
2. obj.innerText = "XXX"; There seems to be problems occasionally in FF. Change to obj .innerHTML = "XXX"; will do.
3. var olE = document.body.onload; Get the onload function of the body. IE is fine, but FF is not. Change it to window.onload. Solved.
As for window What is the difference between .onload and body.onload... It remains to be seen by Baidu.
4. In IE, the .event object has x, y attributes. FF does not. In FF, event.x should be event.pageX
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 means asynchronous
No problem in IE and FF. But xmlHttp.open("get","xxx.aspx?id=xx",false); works fine in IE but not in FF!!
This problem has not been solved yet.
6. It’s time to eat. To be continued..
----------
The fifth one is solved.
Write like this when calling synchronously.

Copy code 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.");
}
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn