我遇到来自第三方无法正常工作的脚本的问题。我得到的错误是:
"未捕获TypeError:jQuery(...)。imageMapper不是函数"
我试过几次解决这个问题,似乎没什么用。非常感谢任何帮助或想法。以下是剧本:
(function() {
var mapper_63_loadScript = function(url, success) {
var script = document.createElement('script');
script.src = url;
var head = document.getElementsByTagName('head')[0],
done = false;
script.onload = script.onreadystatechange = function() {
if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) {
done = true;
success();
script.onload = script.onreadystatechange = null;
head.removeChild(script);
}
};
head.appendChild(script);
};
var mapper_63_execute_scripts = function() {
jQuery('.imagemapper63-wrapper').imageMapper({
itemOpenStyle: 'click',
itemDesignStyle: 'responsive',
responsiveWidth: 600,
transformSmall: 1,
oldResponsive: 0,
animateOther: 1000,
pinScalingCoefficient: 1,
advancedPinOptions: true,
pinClickAction: "content",
pinHoverAction: "my_content",
useTransitions: '1',
animationDuration: 170,
mapOverlay: true
});
};
if ((typeof jQuery === 'undefined') || (parseInt(jQuery.fn.jquery) === 1 && parseFloat(jQuery.fn.jquery.replace(/^1\./, "")) < 9.1)) {
mapper_63_loadScript('//code.jquery.com/jquery-2.2.3.min.js', function() {
mapper_63_loadScript('https://easy-image-mapper.herokuapp.com/shopify_image_mapper.js?shop=mustaevusa.myshopify.com', function() {
mapper_63_execute_scripts();
});
});
} else {
mapper_63_loadScript('https://easy-image-mapper.herokuapp.com/shopify_image_mapper.js?shop=mustaevusa.myshopify.com', function() {
mapper_63_execute_scripts();
});
}
})();
答案 0 :(得分:1)
将调用移至mapper_63_execute_scripts();
到第7行的readystate处理程序内。
您尝试在浏览器中提供该代码之前调用该代码。