一個js函式,代碼如下:
ol.dom.outerWidth = function(element) {
if(navigator.userAgent.indexOf("MSIE")!=-1) {
var width = element[0].offsetWidth;
var style = element[0].currentStyle || window.getComputedStyle(element[0]);
}
else{
var width = element.offsetWidth;
var style = element.currentStyle || window.getComputedStyle(element);
}
width += parseInt(style.marginLeft, 10) + parseInt(style.marginRight, 10);
return width;
};
Microsoft Edge瀏覽器(版本 87.0.664.66 (官方內部版本,64位) 出錯,出錯代碼在window.getComputedStyle(element);這句,錯誤資訊是:ol-debug.js:47206 Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/244992.html
標籤:JavaScript
上一篇:getComputedStyle() 在window 一直報錯
下一篇:獲取function內的資料
