无法在我的页面中使用API​​添加环聊按钮

时间:2015-10-31 11:09:28

标签: javascript html5 google-api hangout

我正在尝试的是添加一个基本的环聊按钮组件,该组件将启动Google的环聊。我正在按照Google Developer中提到的步骤进行操作,但经过所有努力,我正在努力解决以下问题:

Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('file://') does not match the recipient window's origin ('null').(anonymous function) @ core:rpc:shindig.random:shindig.sha1.js?c=2:838
3cb=gapi.loaded_0:112 Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('file://') does not match the recipient window's origin ('null').(anonymous function) @ cb=gapi.loaded_0:112

以下是我用于在页面中制作视频群聊按钮的片段:

<script src="https://apis.google.com/js/platform.js"></script>
    <div id="placeholder-div"></div>
    <script>
    window.____gcfg = {
      lang: 'en-US',
      parsetags: 'onload'
    };
      gapi.hangout.render('placeholder-div', {
          'render': 'createhangout',
          'initial_apps': [{'app_id' : '902502537504'}],
          'widget_size': 175
        });
    </script>

我还使用https://console.developers.google.com/project/grabhouseportal/apiui/apiview/plusHangouts/overview

启用了我的Google +环聊服务

感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

注意body { border-top: 15px solid #F2828E; background-color: #EEEEEE; margin: 0; } 。不要直接使用浏览器打开html文件。您需要运行本地Web服务器并导航到localhost以呈现html页面。