【发布时间】:2016-11-11 19:20:36
【问题描述】:
我在尝试在 Facebook 上共享带有参数的页面时遇到问题。这是我正在使用的代码:
function PopupCenter(url, title, w, h) {
var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : screen.left;
var dualScreenTop = window.screenTop != undefined ? window.screenTop : screen.top;
var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width ;
var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;
var left = ((width / 2) - (w / 2)) + dualScreenLeft ;
var top = ((height / 2) - (h / 2)) + dualScreenTop ;
var newWindow = window.open(url, title, 'scrollbars=yes, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
}
网址是:
https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2127.0.0.1%3A50846%2FIndex.html%3Faction%3DDO1%26param%3D4cf13a1311fe40afa401b25ef7fa0379f1f7c1930a04f8755d678474d0c30e0c
这里其实有两个参数:
- action=DO1,并且
- param=4cf13a1311fe40afa401b25ef7fa0379f1f7c1930a04f8755d678474d0c30e0c
最初,我没有对共享 URL 进行编码(意思是使用 =、/、& 字符)并且共享有效,但缺少参数。现在我正在输入一个编码的 URL,Facebook 的窗口会弹出但立即消失。
谁能告诉我如何在无需切换到 Feed 共享机制的情况下共享带有参数的 URL?
提前致谢。
【问题讨论】:
-
你为什么要分享一个 localhost url?这没有任何意义......
-
我目前在测试环境中工作。我现在唯一想看到的是嵌入到 Facebook 分享帖子中的链接是正确的。只要它根据需要工作,就会将 URL 更正为实际值。
-
尝试使用公共 url,而不是使用 localhost。你不能那样测试它。
-
好的。会做并发布结果。