【问题标题】:Google Plus button code warns: "Unsafe JavaScript attempt to access frame" in ChromeGoogle Plus 按钮代码警告:Chrome 中的“不安全的 JavaScript 尝试访问框架”
【发布时间】:2011-12-06 12:30:56
【问题描述】:

我正在尝试向我的网站添加一个 Google Plus 按钮,并不断收到 JavaScript 安全警告,尽管我在 Chrome 上使用的是 Google 推荐的代码。

我已经使用直接从 Google 网站管理员的 recommended code 复制的代码复制了错误,没有其他添加:

<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 网站管理员推荐的代码是不是很不安全?还是我做错了什么?

【问题讨论】:

    标签: javascript google-chrome google-plus google-plus-one


    【解决方案1】:

    这是社交插件抛出的常见警告。 Twitter 和 Facebook 插件通常也会发出此警告。您可以放心地忽略它。

    【讨论】:

    • 好的,谢谢,虽然这让调试很痛苦。我已经在 G+ 开发者列表中标记了这个问题,希望他们能解决它。
    • FWIW,这不是要解决的 Google(或 Twitter 或 Facebook)问题。这是一个已知的 WebKit 错误,它已经存在了一段时间,听起来不会很快得到修复。
    • @monsur 插件提供者可以做出开发选择以避免警告,但这并不值得。
    猜你喜欢
    • 2011-08-05
    • 2010-10-25
    • 2011-05-18
    • 2011-09-25
    • 2013-02-02
    • 1970-01-01
    • 2012-05-26
    • 2012-06-21
    相关资源
    最近更新 更多