我有一个包含 Fancybox 和 Pinterest pin 按钮的页面。两者似乎都可以正常工作,但是当我关闭 Fancybox 覆盖时,我看到以下 JavaScript 错误:
Uncaught TypeError: Cannot read property 'data-pin-aha' of null
我的 Pinterest 按钮呈现如下:
<a href="http://pinterest.com/pin/create/button/?url=http://www.mywebsite.com/somepage&media=http://www.mywebsite.com/content/images/2c63a4e0-3b65-4464-934c-77f2a7166090-Dim459X612.jpg&description=some description" class="PIN_1354830754034_pin_it_button PIN_1354830754034_pin_it_beside PIN_1354830754034_hazClick" data-pin-aha="button_pinit" data-pin-config="beside"><span class="PIN_1354830754034_pin_it_button_count" id="PIN_1354830754034_pin_count_0"><i></i>3</span></a>
只是为了好玩,我的 Pinterest 按钮正在异步加载:
(function () {
window.PinIt = window.PinIt || { loaded: false };
if (window.PinIt.loaded) return;
window.PinIt.loaded = true;
function async_load() {
var s = document.createElement("script");
s.type = "text/javascript";
s.async = true;
if (window.location.protocol == "https:")
s.src = "https://assets.pinterest.com/js/pinit.js";
else
s.src = "http://assets.pinterest.com/js/pinit.js";
var x = document.getElementsByTagName("script")[0];
x.parentNode.insertBefore(s, x);
}
if (window.attachEvent)
window.attachEvent("onload", async_load);
else
window.addEventListener("load", async_load, false);
})();
还有我的 Fancybox 链接:
<a href="//vimeo.com/36573701" class="watch"><span>Watch Our Story</span></a>
总的来说,这是一个非常基本的设置。只是为了好玩,我为 Pinterest 使用了普通的内联脚本标签,但得到了同样的错误。
有没有人见过这个错误并知道如何解决它?