谷歌加号按钮代码警告:“Unsafe JavaScript attempt to access frame”在Chrome中。

43

我试图在我的网站上添加Google Plus按钮,但是尽管我使用了谷歌推荐的代码,在Chrome浏览器中仍然会收到JavaScript安全警告。

我已经复制了来自Google Webmaster 推荐代码,并且没有做出任何其他修改,但错误仍然存在:

<html itemscope itemtype="http://schema.org/">
<head>
<meta itemprop="name" content="Title">
<meta itemprop="description" content="Description">
</head>
<body>
<g:plusone annotation="inline"></g:plusone>
<script type="text/javascript">
  (function() {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')\[0\]; s.parentNode.insertBefore(po, s);
  })();
</script>
</body>

在Chrome(Mac上的15版)中加载此内容,开发者控制台会发出警告:

Unsafe JavaScript attempt to access frame with URL http://mydomain.com/ 
from frame with URL https://plusone.google.com/_/+1/fastbutton?url=http%3A%2F%2Fmydomain.com%2F&size=standard&count=true&annotation=inline&hl=en-US&jsh=m%3B%2F_%2Fapps-static%2F_%2Fjs%2Fwidget%2F__features__%2Frt%3Dj%2Fver%3Dt6mt7PFQYRQ.en_GB.%2Fsv%3D1%2Fam%3D!agWx4Vf_ACSIFA91ZQ%2Fd%3D1%2F#id=I1_1323174311773&parent=http%3A%2F%2Fmydomain.com&rpctoken=352111652&_methods=onPlusOne%2C_ready%2C_close%2C_open%2C_resizeMe. 
Domains, protocols and ports must match.

Google网站管理员建议的代码是不安全的吗?还是我做错了什么?

1个回答

30

这是社交插件常见的警告。Twitter和Facebook插件通常也会出现此警告。您可以安全地忽略它。


13
好的,谢谢。尽管这使得调试很麻烦,但我已经向G+开发者列表标记了这个问题,希望他们会解决它。 - Richard
1
就此而言,这不是谷歌(或Twitter或Facebook)需要解决的问题。这是一个已知的WebKit漏洞,已经存在一段时间了,听起来似乎不会很快得到修复。 - monsur
@monsur 插件提供者可以做出开发选择以避免警告,但这并不值得努力。 - abraham

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接