gpt4 book ai didi

php - 如何在 jQuery 中使用 header 位置?

转载 作者:行者123 更新时间:2023-12-03 21:51:23 24 4
gpt4 key购买 nike

我可以使用 jQuery 中的 header 位置进行重定向或刷新吗?

就像 PHP 中一样:

header('location:www.google.co.in');
header("Refresh:1,url=home.php");

如果没有,有什么替代方法?

最佳答案

header 在文档呈现之前以及 jQuery 加载之前进行解释,因此这些不是一个选项。相反,您可以使用 document.location 重定向浏览器。

document.location.href = 'www.google.co.in';

对于 jQuery 方法,您可以使用

$(location).attr('href', 'www.google.co.in');

但是我更喜欢纯 JavaScript 版本。

关于php - 如何在 jQuery 中使用 header 位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20919998/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com