如何打开类似Facebook的Twitter弹出窗口

问题描述 投票:0回答:1
$('.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'
    );
});

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

也在新选项卡上-文本框内-网址前有一个空格

javascript share
1个回答
0
投票

根据评论,似乎您的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'
    );
});
© www.soinside.com 2019 - 2024. All rights reserved.