$('.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'
);
});
上述工作正常,我希望对twitter也一样:
$('.twshare').on('click', function(){
var url = window.location.href;
window.open('https://twitter.com/share?url=' + url,
'width=800,height=600'
);
});
这将打开一个新选项卡,而不是一个弹出窗口
也在新选项卡上-文本框内-网址前有一个空格
根据评论,似乎您的Twitter示例中省略了window.open()的第二个参数windowName
。试试这个:
$('.twshare').on('click', function () {
var url = window.location.href;
window.open('https://twitter.com/share?url=' + url,
'twitter-share-dialog',
'width=800,height=600'
);
});