当前位置: 首页 > 图文教程 > 网络编程 > Javascript > Javascript 兼容firefox的一些问题

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

Javascript 兼容firefox的一些问题


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 415 ::
收藏到网摘: n/a

上午在做一些测试.把页面拿到火狐上去就出现一堆问题.页面布局先不说.Javascript代码的问题就够头疼 比如:
1. document.all() 在FF里不行. 必须改成document.getElementById();
2. obj.innerText = "XXX"; 在FF里好像偶尔也有问题. 换成obj.innerHTML = "XXX";就行了.
3. var olE = document.body.onload; 获得body的onload函数. IE没问题.FF不行.改成window.onload.解决.
至于window.onload和body.onload有什么区别.. 还有待百度一下.
4. 在IE中.event对象有x,y属性. FF没有. event.x在FF里应该是event.pageX
解决办法. mX = event.x ? event.x : event.pageX; 然后用 mX 代替 event.x.
5. 最可恨的是Ajax在FF里不能同步调用!!!
比如 xmlHttp.open("get","xxx.aspx?id=xx",true); //true表示异步
在IE和FF里都没问题。 但是 xmlHttp.open("get","xxx.aspx?id=xx",false); 在IE没问题.在FF里就不行!!
这个问题还没找到解决办法.
6. 要吃饭了.未完待续..
-----------
第5个解决了.
同步调用的时候这样写.
复制代码 代码如下:

xmlHttp.open("get","xxx.aspx?id=xx",false);
xmlhttp.send(null);
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200) {
// alert(xmlhttp.responseText);
} else {
alert("您所请求的页面有异常。");
}
}