Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.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 谷歌&x2B;-如何在不单击按钮的情况下打开交互式帖子对话框?_Javascript_Google Plus_Interactive - Fatal编程技术网

Javascript 谷歌&x2B;-如何在不单击按钮的情况下打开交互式帖子对话框?

Javascript 谷歌&x2B;-如何在不单击按钮的情况下打开交互式帖子对话框?,javascript,google-plus,interactive,Javascript,Google Plus,Interactive,有没有一种方法可以在不先单击按钮的情况下打开对话框? 我想有一个网站直接显示它 下面是G+示例中的相关代码 JavaScript: <script type="text/javascript"> (function() { var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://apis.google.com/j

有没有一种方法可以在不先单击按钮的情况下打开对话框? 我想有一个网站直接显示它

下面是G+示例中的相关代码

JavaScript:

<script type="text/javascript">
  (function() {
   var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
   po.src = 'https://apis.google.com/js/client:plusone.js';
   var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
 })();
</script>

(功能(){
var po=document.createElement('script');po.type='text/javascript';po.async=true;
po.src=https://apis.google.com/js/client:plusone.js';
var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(po,s);
})();
HTML:


告诉你的朋友

向该按钮元素添加一个id(您可以完全使用不同的元素,只要您包含所有提供的属性——未经测试无法确定),并将其设置为隐藏。 从那里,只要在你想要的任何事件上点击它就行了

即。 HTML:

JS:


(功能(){
var po=document.createElement('script');po.type='text/javascript';po.async=true;
po.src=https://apis.google.com/js/client:plusone.js';
var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(po,s);
$('#something')。悬停(函数(){
$(“#此按钮”)。单击();
});
})();

如果你模拟点击它会发生什么?面对同样的问题,请给出一些解决方案,下面的答案不起作用是的,ID不是真的必要,但你可能希望在一个页面或其他地方包含多个,所以我认为它更具前向兼容性。如果最终需要n个元素,则需要使用触发事件的元素与button(或whatver)元素之间的关系。i、 e.
$('#thing').hover(函数(){$(this.prev().parent().next().children('.thisisawardexample')。单击();})我尝试了你的例子,但是G+共享框没有出现。我错过什么了吗?
<button
      class="g-interactivepost"
      data-contenturl="https://plus.google.com/pages/"
      data-contentdeeplinkid="/pages"
      data-clientid="xxxxx.apps.googleusercontent.com"
      data-cookiepolicy="single_host_origin"
      data-prefilltext="Engage your users today, create a Google+ page for your business."
      data-calltoactionlabel="CREATE"
      data-calltoactionurl="http://plus.google.com/pages/create"
      data-calltoactiondeeplinkid="/pages/create">
      Tell your friends
    </button>
<button
  id="thisdumbbutton"
  class="g-interactivepost"
  data-contenturl="https://plus.google.com/pages/"
  data-contentdeeplinkid="/pages"
  data-clientid="xxxxx.apps.googleusercontent.com"
  data-cookiepolicy="single_host_origin"
  data-prefilltext="Engage your users today, create a Google+ page for your business."
  data-calltoactionlabel="CREATE"
  data-calltoactionurl="http://plus.google.com/pages/create"
  data-calltoactiondeeplinkid="/pages/create">
  Tell your friends
</button>
#thisdumbbutton{ display: none; }
<script type="text/javascript">
  (function() {
   var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
   po.src = 'https://apis.google.com/js/client:plusone.js';
   var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);

   $('#something').hover(function(){
      $('#thisdumbbutton').click();
   });
  })();
</script>