JavaScript在IE與Firefox幾個寫法不同的地方

jiestyle21發表於2011-11-01
//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";



相關文章