Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/427.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过javascript添加的Google plus按钮->;仅在页面重新加载后显示[GWT应用程序]_Javascript_Gwt_Iframe_Google Plus - Fatal编程技术网

通过javascript添加的Google plus按钮->;仅在页面重新加载后显示[GWT应用程序]

通过javascript添加的Google plus按钮->;仅在页面重新加载后显示[GWT应用程序],javascript,gwt,iframe,google-plus,Javascript,Gwt,Iframe,Google Plus,我有一个GWT应用程序,我使用“GWT活动和地点”进行导航、浏览历史等。现在我尝试合并GooglePlus按钮,这样用户就可以推荐单个特定的文章。正如您在第一个屏幕截图中看到的,我在页脚上也有一个google plus按钮。该页面直接包含在主机页面(HTML页面)中,并在第一次页面加载时显示。第二个是文章小部件的一部分,因此通过javascript添加到主机页。这一个不会显示在第一次页面加载中,但如果我重新加载页面(请参见按F5后的第二个屏幕截图)。那个问题有什么解决办法吗 我对类似facebo

我有一个GWT应用程序,我使用“GWT活动和地点”进行导航、浏览历史等。现在我尝试合并GooglePlus按钮,这样用户就可以推荐单个特定的文章。正如您在第一个屏幕截图中看到的,我在页脚上也有一个google plus按钮。该页面直接包含在主机页面(HTML页面)中,并在第一次页面加载时显示。第二个是文章小部件的一部分,因此通过javascript添加到主机页。这一个不会显示在第一次页面加载中,但如果我重新加载页面(请参见按F5后的第二个屏幕截图)。那个问题有什么解决办法吗

我对类似facebook的按钮也有同样的问题。我可以通过从HTML5版本切换到iFrame版本来解决这个问题。还有其他版本的google plus按钮吗

这是我的密码。首先,我要介绍google plus脚本:

<script type="text/javascript">
  window.___gcfg = {
    lang: 'en-US'
  };

  (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>

窗口。\uuuuuu gcfg={
朗:“恩我们”
};
(功能(){
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);
})();
此代码添加了按钮:

<div class='g-plusone' data-annotation='inline' data-width='300' data-href='http://gwt-prime.appspot.com/fb/ArticleSection/4'></div>

屏幕截图:

缺少页面->按钮的首次加载:

重新加载页面后->按钮显示:

示例链接


要自己查看页面,请查看此处:

在站点完全呈现后,尝试调用此jsni片段:

/**
 * Render any Google+ button inside of the container identified by containerId.
 */
static public native void go(String containerId) /*-{
    $wnd.gapi.plusone.go(containerId);
}-*/;