JS相容問題總結

2022-08-20 11:42:11 字數 717 閱讀 7684

//1.. 阻止事件冒泡的相容

if

(event.stoppropagation)

else

//2.阻止預設瀏覽器事件的相容

function stopdefault(event

) else

}

//3.事件解綁的相容

function bind(ele,type,callback)

else}//

- ele:將要繫結事件的物件

//- type:事件型別

//- callback:處理事件的函式

//4..獲取鍵盤資訊的相容

e.keycode || e.which

//5.事件委託

e.target || e.sceelement

//6.獲採樣式的及相容

function getstyle(ele,attr)

else

}

//7..獲取滾動距離的相容

var stop = document.documentelement.scrolltop || document.body.scrolltop

//8.事件物件的相容

function fn(eve)

js相容問題總結

01 獲取滾動條滾動的距離 var stop document.documentelement.scrolltop document.body.scrolltop 02 獲取非行間樣式 ie currentstyle attr 標準 getcomputedstyle attr function ge...

js相容問題

獲取非行內樣式的相容方式 複製 function getstyle obj,attr else 複製 獲取事件物件的相容方式 document.nclick function eve 事件冒泡的相容方法 複製 function stopbubble e else 複製 阻止瀏覽器預設行為的相容方法 ...

最新相容問題總結

相容問題解決方案。1 在做 之前,先把下邊三句meta加入頁面。2 pc端相容瀏覽器不能用 html5 新增的標籤。3 偽元素也不能用,在移動端可以用。4 如果想針對某乙個瀏覽器,設定單獨的屬性值,可以 如 class 針對 ie7特製識別的 css樣式 html class 針對ie8特製識別的c...