共享和下载链接在Facebook应用程序内移动浏览器中不起作用

时间:2018-10-10 10:15:35

标签: javascript jquery facebook

我有三个链接可生成图像,然后在页面上共享图像或直接下载图像。

不幸的是,这些链接都无法在Facebook应用内浏览器中正常工作。在我尝试过的所有其他浏览器中,它们似乎都能正常工作。我可以对点击时调用的代码做些什么?

我猜这两个社交链接由于“ window.open”命令而无法正常工作?我应该以某种方式使其附加为点击按钮的链接吗?

感谢任何帮助或指导。

$(document).ready(function() {
        $('.facebook').click(function() {

            var path = new String(window.location);
            var resultPath = 'https://website.com/generator/share/?img=<?=$file?>';
            var fbpopup = window.open("https://www.facebook.com/sharer/sharer.php?hashtag=%23hashtag&u=" + resultPath, "_blank", "width=600, height=400, scrollbars=no");


        });    

        $('.twitter').click(function() { 
            var path = new String(window.location);
            var resultPath = 'https://website.com/generator/share/?img=<?=$file?>';
            var twShareLink = 'text=Check out my personalized image and create your own! %23hashtag &url=' + resultPath;
            var twpopup = window.open("http://twitter.com/intent/tweet?" + twShareLink , "_blank", "width=600, height=400, scrollbars=no");
        }); 

        $('.download').click(function() {
            var downloadLink = document.createElement("a");
            downloadLink.href = '<?=$url?>';
            downloadLink.download = 'image.jpg';
            document.body.appendChild(downloadLink);
            downloadLink.click();
            document.body.removeChild(downloadLink);
        });   
});

0 个答案:

没有答案