![](/img/trans.png)
[英]IntersectionObserver undefined for Internet Explorer
[英]'DataTransferItem' is undefined in internet explorer
我想檢查瀏覽器中是否存在DataTransferItem對象。 為此,我寫了以下代碼:
$(document).ready(function(){ if(DataTransferItem) { $('#supported').show(); } else { $('#notsupported').show(); } });
現在我正在測試Internet Explorer 11.它拋出錯誤“'DataTransferItem'未定義”並且我的腳本被殺死了。 但這就是我想要測試的。
您應該使用“窗口”參考進行檢查,如下所示
$(document).ready(function(){
if(window.DataTransferItem)
{
$('#supported').show();
}
else
{
$('#notsupported').show();
}
});
if (window["DataTransferItem"]){}
或Object.hasOwnProperty()
if (window.hasOwnProperty("DataTransferitem")){}
請使用括號表示法
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.