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

来源:互联网 发布:c语言中的string.h 编辑:程序博客网 时间:2024/05/11 03:53
//css floatdocument.getElementById("header").style.styleFloat = "left";   //iedocument.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";


原创粉丝点击