我们网站上有一个中央网页,可根据某些条件将用户重定向到某个特定页面。重定向逻辑是使用 window.location.href 在 JavaScript 中编码的,但此重定向在 Facebook 应用程序浏览器中总是失败,但它在除 Facebook 应用程序内浏览器版本 323 之外的所有其他移动浏览器中运行良好。
我已经尝试了下面列出的所有其他可能的 JavaScript 重定向选项,但它们似乎都失败了。
<html><body><script type='text/javascript'> window.open("http://conv-test.mnetads.com/client-side-second-hop/");</script></body>
<html><body><script type='text/javascript'> eval('window.location.href ="http://conv-test.mnetads.com/client-side-second-hop/"');</script></body>
<html><body><script type='text/javascript'> setTimeout(window.location.href ="http://conv-test.mnetads.com/client-side-second-hop/", 10000);</script></body>
<html><body><script type='text/javascript'> setTimeout(window.onload = function(e){ location.replace("http://conv-test.mnetads.com/client-side-second-hop/"); }, 5000);</script></body>
<html><body><script type='text/javascript'> window.location ="http://conv-test.mnetads.com/client-side-second-hop/";</script></body></html>
// Sets the new location of the current window.
<html><body><script type='text/javascript'> window.location.assign("http://conv-test.mnetads.com/client-side-second-hop/");</script></body></html>
// Assigns a new URL to the current window.
<html><body><script type='text/javascript'> window.location.replace("http://conv-test.mnetads.com/client-side-second-hop/");</script></body></html>
// Replaces the location of the current window with the new one.
<html><body><script type='text/javascript'> self.location ="http://conv-test.mnetads.com/client-side-second-hop/";</script></body></html>
// Sets …Run Code Online (Sandbox Code Playgroud) 从登录开始,我就在我的网站上使用 Facebook 登录 Javascript SDK,但最近它在 Android Facebook 应用程序内浏览器中停止工作。当我单击登录按钮时,它会重新加载完整页面以转到授权页面,然后返回时什么也没有
Facebook 提供的示例也有同样的问题,甚至使用 FB.login 功能和 Facebook 登录按钮(https://developers.facebook.com/docs/facebook-login/web/login-button)进行了测试。得到了相同的结果。它只是刷新页面。
示例代码:
<script>
function LoggedFb(){
FB.login(function (response) {
FB.api(`/me?fields=id,email&access_token=${response.authResponse.accessToken}`, function
(userResponse) {
alert(userResponse.email);
});
}, { scope: 'email' })
}
</script>
Run Code Online (Sandbox Code Playgroud)
该代码适用于除 Android Facebook 应用内浏览器之外的所有平台。
谢谢。
javascript facebook facebook-javascript-sdk facebook-login facebook-browser
JavaScript 重定向已停止在应用程序和浏览器中的最新版本的 facebook 上运行。尝试了
window.location.replace({url})很多不同的方法,但没有效果。包括:
关于它为什么不起作用的任何建议?