我正在与客户合作,帮助他们在其网站上实现 Google 可信商店。该代码已在 Chrome 和 Firefox 中验证,但在 IE 中未验证。
原因是因为实际的“validator”元素没有出现。因此,没有任何错误可供查看或发生任何事情,它只是不显示。
Google 的文档仅指出,如果代码未显示,则徽章代码要么重复,要么丢失。然而,情况并非如此,因为它甚至不会显示在除该脚本之外没有任何代码的网站版本上。
以下是主页上显示的与脚本相关的代码:
<script type="text/javascript">
var gts = gts || [];
gts.push(["id", "STORE_ID_HERE"]); // Note: value removed for privacy
gts.push(["badge_position", "BOTTOM_LEFT"]);
gts.push(["locale", "en_US"]);
// This is a "platform hack" to support the cart they're on
// insures that the ProductID value is only transmitted on the right pages
if( $('body').hasClass('category-page-type') || $('body').hasClass('search-page') || $('body').hasClass('recommended-products-page') || $('body').hasClass('product-page-type') )
{
gts.push(["google_base_offer_id", currentProductId]); // loads variable from input on product pages
}
gts.push(["google_base_subaccount_id", "ID_HERE"]); // Also removed for privacy
gts.push(["google_base_country", "US"]);
gts.push(["google_base_language", "en"]);
(function() {
var gts = document.createElement("script");
gts.type = "text/javascript";
gts.async = true;
gts.src = "https://www.googlecommerce.com/trustedstores/api/js";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(gts, s);
})();
</script>
此代码适用于 Firefox/Chrome,但不适用于 IE11(仅经过测试的版本,Google 需要支持 9+)。
我还在动态生成的文件之一中发现了此错误(也在 IE11 控制台中),但我真的不确定为什么:
Failed to open http://www.googlecommerce.com/trustedstores/s/tm2?id=17172&jsv=sDipv1xMSq4&hl=en_US&xpc={"cn"%3A"q9GW00NhHi"%2C"tp"%3Anull%2C"osh"%3Anull%2C"ppu"%3A"http%3A%2F%2Fwww.greenelectricalsupply.com%2Frobots.txt"%2C"lpu"%3A"http%3A%2F%2Fwww.googlecommerce.com%2Frobots.txt"}
控制台错误显示为跨源限制,但由于某种原因,这对我来说似乎并不正确。
此链接会导致验证器出现:http://bit.ly/15LbcaL
您会注意到它在 Chrome/Firefox 中显示,但在 IE 中不显示(尚未测试 9/10,但 11 肯定不起作用)。我实际上已经联系了谷歌,但还没有收到回复。如有任何帮助,我们将不胜感激。
更新
Google 表示问题是 Window.prototype 未定义,但我对这个答案不太有信心,因为验证器栏(以及有问题的脚本)在其他浏览器中运行良好,但在这个浏览器中不行。
最佳答案
不确定您是否已解决此问题,但我遇到了同样的问题,并向 Google 寻求帮助并建议这样做:
我在头部有这个元代码:
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
这些 IE7 和 IE8 元数据阻止了徽章加载。
然后他们说只添加这个:
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
这非常简单,而且对我来说很有效。 希望它能帮助您解决问题,或者至少也能帮助某人。
关于javascript - Google Trusted Stores Test Drive 未在 IE11 中显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28217204/