Javascript 启动模式中的Twitter共享按钮在firefox上不起作用

Javascript 启动模式中的Twitter共享按钮在firefox上不起作用,javascript,html,firefox,twitter,bootstrap-modal,Javascript,Html,Firefox,Twitter,Bootstrap Modal,我有两个twitter共享按钮,一个在身体上,另一个在引导模式内 这两个共享按钮都可以在chrome上使用,但不能在Firefox上使用。在Firefox上,第一个共享按钮在外部模式下工作,但是当我打开模式时,我看不到共享按钮 是虫子吗?这个问题有解决办法吗 这是我的密码 window.twttr=(函数(d,s,id){ var t,js,fjs=d.getElementsByTagName[0]; if(d.getElementById(id))返回;js=d.createElement

我有两个twitter共享按钮,一个在身体上,另一个在引导模式内

这两个共享按钮都可以在chrome上使用,但不能在Firefox上使用。在Firefox上,第一个共享按钮在外部模式下工作,但是当我打开模式时,我看不到共享按钮

是虫子吗?这个问题有解决办法吗

这是我的密码


window.twttr=(函数(d,s,id){
var t,js,fjs=d.getElementsByTagName[0];
if(d.getElementById(id))返回;js=d.createElement;js.id=id;
js.src=”https://platform.twitter.com/widgets.js“fjs.parentNode.insertBefore(js,fjs);
return window.twttr | |(t={ue:[],ready:function(f){t.e.push(f)});
}(文件,“脚本”、“推特wjs”);
模态示例
开放模态
&时代;
模态头
接近

这看起来像个bug,因为小部件按钮隐藏在Firefox和Twitter提供的css中。然而,我已经找到了解决方法——基本上你可以自己创建缺少的按钮

1) 将
模态体的内容更改如下:

<div class="modal-body">
    <a href="https://twitter.com/intent/tweet">
        <i class="btn-icon"></i>
        <span class="btn-text">Tweet</span>
    </a>
</div>
3) 添加jQuery事件处理程序

$(document).ready(function(){
    $('.modal-body a .btn-icon, .modal-body a').hover(function(){
        $('.modal-body a .btn-icon, .modal-body a')
        .css('background-color', '#0c7abf');
    },
    function(){
        $('.modal-body a .btn-icon, .modal-body a')
        .css('background-color', '#1b95e0');
    })
})
就这样。现在你们在FF和Chrome的弹出窗口中有了按钮。如有必要,您可以调整按钮和图标的样式,使其看起来更好

工作示例:


希望这有帮助。

或者直接用jQuery克隆按钮:

$(function() {
  $('#myModal').on('shown.bs.modal', function(e) {
    if ($(".modal-body").find('.twitter-share-button').size())
        return;

    $('.twitter-share-button:first').clone().appendTo('.modal-body');
  });
});

好主意,但“两个共享”按钮有两个不同的用途,并且在这些按钮上附加了两个不同的回调。
$(document).ready(function(){
    $('.modal-body a .btn-icon, .modal-body a').hover(function(){
        $('.modal-body a .btn-icon, .modal-body a')
        .css('background-color', '#0c7abf');
    },
    function(){
        $('.modal-body a .btn-icon, .modal-body a')
        .css('background-color', '#1b95e0');
    })
})
$(function() {
  $('#myModal').on('shown.bs.modal', function(e) {
    if ($(".modal-body").find('.twitter-share-button').size())
        return;

    $('.twitter-share-button:first').clone().appendTo('.modal-body');
  });
});