[英]Console Error in Chrome: window.function is not a function
在chrome中,我的JS收到以下錯誤:
Uncaught TypeError: window.picturefill is not a function
我該如何解決?
function activateVisiblePicturefills() {
jQuery("span").each(function(i, elm) {
var $elm = jQuery(elm);
if (checkvisible($elm)) {
var content = $elm.html(),
$pic = jQuery("<picture id=" + $elm.attr("id") + ">" + content + "</picture>").addClass($elm.attr("class")),
pic = $pic[0];
$elm.after($pic); // insert the picture
$elm.remove(); // remove the span
window.picturefill({ elements: [ pic ] });
}
});
}
如果您包含了picturefill.js腳本,則該腳本位於全局名稱空間中
而不是打電話
window.picturefill()
只是打電話
picturefill();
一般而言,全局名稱空間是窗口對象,在瀏覽器中作為標准對象調用時,但這是例外。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.