当前位置: 首页 > 图文教程 > 网络编程 > Javascript > ie和firefox不兼容的解决方法集合

Javascript
Add a Table to a Word Document
Add Formatted Text to a Word Document
用jscript实现新建word文档
用jscript实现新建和保存一个word文档
Open and Print a Word Document
Use Word to Search for Files
Convert Seconds To Hours
Sample script that deletes a SQL Server database
Sample script that displays all of the users in a given SQL Server DB
firefox中用javascript实现鼠标位置的定位
div+css实现鼠标放上去,背景跟图片都会变化。
Locate a File Using a File Open Dialog Box
Save a File Using a File Save Dialog Box
用jscript实现列出安装的软件列表
List the Stored Procedures in a SQL Server database
Display SQL Server Login Mode
Display SQL Server Version Information
List all the Databases on a SQL Server
用jscript启动sqlserver
Stop SQL Server

Javascript 中的 ie和firefox不兼容的解决方法集合


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

网页设计很多情况下,需要注意ie跟firefox的不同区别,软晨学习网提供了不好这样的文章,大家可以好好看下。 1、firefox和ie事件event处理
在ie中,事件对象是作为一个全局变量来保存和维护的。 所有的浏览器事件,不管是用户触发
的,还是其他事件, 都会更新window.event 对象。 所以在代码中,只要轻松调用 window.event
就可以轻松获取 事件对象, 再 event.srcElement 就可以取得触发事件的元素进行进一步处理
在ff中, 事件对象却不是全局对象,一般情况下,是现场发生,现场使用,ff把事件对象自动传
递给对应的事件处理函数。 在代码中,函数的第一个参数就是ff下的事件对象了。
<button id="btn4" onclick="foo4()">按钮4</button>
<script>
function foo4(){
var evt=getEvent();
var element=evt.srcElement || evt.target ;
alert(element.id)
}
function getEvent()
{ //同时兼容ie和ff的写法
if(document.all) return window.event;
func=getEvent.caller;
while(func!=null){
var arg0=func.arguments[0];
if(arg0){
if((arg0.constructor==Event || arg0.constructor ==MouseEvent) || (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation)){
return arg0;
}
}
func=func.caller;
}
return null;
}
</script>
2、firefox和ie对手型指针cursor不兼容
手型指针有cursor:hand和cursor:pointer两种写法,其中cursor:hand在ff中不支持,返回错误!
只要使用cursor:pointer即可,ff和ie都支持!