如何打开类似facebook的twitter弹出窗口


$('.fbshare').on('click', function(){
var url = window.location.href;
window.open('https://www.facebook.com/sharer/sharer.php?u=' + url,
'facebook-share-dialog',
'width=800,height=600'
);
});

上面的工作原理很好,我想要同样的推特:

$('.twshare').on('click', function(){
var url = window.location.href;
window.open('https://twitter.com/share?url=' + url,
'width=800,height=600'
);
});

这会打开一个新的选项卡,而不是一个弹出窗口

同样在新的选项卡上——在文本框内——url在之前有一个空格

根据注释,它看起来像window.open((的第二个参数,windowName在您的Twitter示例中被遗漏了。试试这个:

$('.twshare').on('click', function () {
var url = window.location.href;
window.open('https://twitter.com/share?url=' + url,
'twitter-share-dialog',
'width=800,height=600'
);
});

最新更新