如何使用重定向方法?

问题描述 投票:0回答:1
javascript html css redirect recaptcha
1个回答
0
投票

你没有正确使用

Location

假设你想使用 vanilla JS:

  • 如果你想模拟某人点击链接,使用

    location.href

  • 如果要模拟 HTTP 重定向,请使用

    location.replace

例子:

// similar behavior as an HTTP redirect
window.location.replace("http://stackoverflow.com"); // or "/redirect.html"

// similar behavior as clicking on a link
window.location.href = "http://stackoverflow.com"; // or "/redirect.html"
© www.soinside.com 2019 - 2024. All rights reserved.