IE和firefox瀏覽器在網頁程式設計方面的區別

2021-08-23 11:55:53 字數 2346 閱讀 1863

1.firefox不支援物件加事件的函式名,如:以下**在ie中能正常顯示,但在firefox中則不能;

function.window.onload() 

function.window.onload()

改為用:

window.onload = fnshow;   

function fnshow() 

window.onload = fnshow;

function fnshow()

或直接寫為:

window.onload = function ()   

//------- 

window.onload = function ()

//-------

2.flash,要設定embed的src屬性才能正常顯示;如:

--------

所以flash要同時設定這兩個屬性;

3.製作細線**:

在ie中可以用bordercolordark="網頁背景色",使得**看起來很細;

但在firefox中不起作用;需給**增加樣式:style="border-collapse:collapse;";

所以要在ie和firefox中都顯示細**,則應該給**加上樣式style="border-collapse:collapse;";

4.在ie中11px和12px顯示的大小是一樣的,但在firefox中11px會比12px小,導致字在firefox中比ie中小;

所以都需設定12px;

5.集合類物件問題

ie下,可以使用()或獲取集合類物件;firefox下,只能使用獲取集合類物件.

解決方法:統一使用獲取集合類物件.

6.自定義屬性問題

ie下,可以使用獲取常規屬性的方法來獲取自定義屬性,也可以使用getattribute()獲取自定義屬性;firefox下,只能使用getattribute()獲取自定義屬性.

解決方法:統一通過getattribute()獲取自定義屬性.

7.event.x與event.y問題

ie下,even物件有x,y屬性,但是沒有pagex,pagey屬性;firefox下,even物件有pagex,pagey屬性,但是沒有x,y屬性.

解決方法:使用mx(mx = event.x ? event.x : event.pagex;)來代替ie下的event.x或者firefox下的event.pagex.

8.event.srcelement問題

ie下,even物件有srcelement屬性,但是沒有target屬性;firefox下,even物件有target屬性,但是沒有srcelement屬性.

解決方法:使用obj(obj = event.srcelement ? event.srcelement : event.target;)來代替ie下的event.srcelement或者firefox下的event.target.

9.window.location.href問題

ie或者firefox2.0.x下,可以使用window.location或window.location.href;firefox1.5.x下,只能使用window.location.

解決方法:使用window.location來代替window.location.href.

10.訪問frame物件:

ie:使用window.frameid或者window.framename來訪問這個frame物件.

firefox:只能使用window.framename來訪問這個frame物件.

另外,在ie和firefox中都可以使用window.document.getelementbyid("frameid")來訪問這個frame物件.

11.window.event問題

window.event只能在ie下執行,而不能在firefox下執行,這是因為firefox的event只能在事件發生的現場使用.

解決方法:

ie:

...   

...ie&firefox:

...   

...下面還有個通用的得到event的方法

function getevent() //同時相容ie和ff的寫法   

}   

func=func.caller;   

}   

return null;   

}  function getevent() //同時相容ie和ff的寫法

}func=func.caller;

}return null;

}到別的方法去直接呼叫就好了

function move()   

IE和firefox瀏覽器在網頁程式設計方面的區別

1.firefox不支援物件加事件的函式名,如 以下 在ie中能正常顯示,但在firefox中則不能 function.window.onload 改為用 window.onload fnshow function fnshow 或直接寫為 window.onload function 2.flas...

firefox和IE瀏覽器相容問題

1.集合類物件問題 說明 ie下,可以使用 或獲取集合類物件 firefox下,只能使用獲取集合類物件.解決方法 統一使用獲取集合類物件.2.html物件獲取問題 firefox document.getelementbyid idname ie document.idname或者document....

IE和Firefox瀏覽器相容問題總結

滑鼠及物件座標控制屬性 offsettop 獲取物件相對於版面或由 offsetparent 屬性指定的父座標的計算頂端位置。offsetleft 獲取物件相對於版面或由 offsetparent 屬性指定的父座標的計算左側位置。offsetheight 獲取物件相對於版面或由父座標 offsetp...