您的位置:首页 > Web前端 > JavaScript

JavaScript在IE与Firefox几个写法不同的地方

2011-11-01 22:14 483 查看
//css float
document.getElementById("header").style.styleFloat = "left";   //ie

document.getElementById("header").style.cssFloat = "left"; //Firefox
//获取IE下鼠标的位置
var myCursorPosition = [0, 0];
myCursorPosition[0] = event.clientX;
myCursorPosition[1] = event.clientY;
//获取FF下鼠标的位置
var myCursorPosition = [0, 0];
myCursorPosition[0] = event.pageX;
myCursorPosition[1] = event.pageY;
/*********************************************************************/
//获取可见区域、窗口的大小IEvar myBrowserSize = [0, 0]; myBrowserSize[0] = document.documentElement.clientWidth; myBrowserSize[1] = document.documentElement.clientHeight; //FFvar myBrowserSize = [0, 0]; myBrowserSize[0]
= window.innerWidth; myBrowserSize[1] = window.innerHeight;
/*********************************************************************/
//下面这个应该是CSS的在IE中这样写: #myElement { filter: alpha(opacity=50); } var myObject = document.getElementById("myElement"); myObject.style.filter = "alpha(opacity=80)"; 在Firefox中这样写: #myElement
{ opacity: 0.5; } var myObject = document.getElementById("myElement"); myObject.style.opacity = "0.5";

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: