【问题标题】:Redirecting automatically to another site in javascript在javascript中自动重定向到另一个站点
【发布时间】:2020-10-26 12:55:27
【问题描述】:

我有一个网站,有移动版和桌面版。但我想以某种方式将它们连接到桌面站点是默认登录页面的位置。因此,如果视口的宽度小于 600 像素(例如),它会自动重定向到移动网站(使用不同的域上传)。我正在使用 React,因此使用 react 的解决方案也可以。有人知道怎么做吗?

【问题讨论】:

标签: javascript html css reactjs mobile


【解决方案1】:
// use this to avoid redirects when a user clicks "back" in their browser
window.location.replace('http://somewhereelse.com');

// use this to redirect, a back button call will trigger the redirection again
window.location.href = "http://somewhereelse.com";

欧文已经在这个问题中回答了: What's the best way to automatically redirect someone to another webpage?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多