如何让浏览器浏览到JavaScript中的URL?(How to get the browser to navigate to URL in JavaScript [duplicate])

编程入门 行业动态 更新时间:2024-10-27 19:15:47
如何让浏览器浏览到JavaScript中的URL?(How to get the browser to navigate to URL in JavaScript [duplicate])

这个问题已经在这里有一个答案:

如何重定向到另一个网页? 70个答案

什么是最好的(正确的,现代的,跨浏览器的,安全的)方式来使网页浏览器使用Javascript导航到您选择的URL?

This question already has an answer here:

How do I redirect to another webpage? 58 answers

What is the best (correct, modern, cross-browser, safe) way to get a web browser to navigate to a URL of your choice using JavaScript?

最满意答案

这适用于所有浏览器:

window.location.href = '...';

如果您希望在浏览器浏览器历史记录中反映该页面,您可以进行以下操作:

window.location.replace('...');

This works in all browsers:

window.location.href = '...';

If you wanted to change the page without it reflecting in the browser back history, you can do:

window.location.replace('...');

更多推荐

本文发布于:2023-08-01 04:44:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1354047.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:浏览器   JavaScript   URL   duplicate   navigate

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!