如何让浏览器在JavaScript中导航到URL [英] How to get the browser to navigate to URL in JavaScript
本文介绍了如何让浏览器在JavaScript中导航到URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用JavaScript让Web浏览器导航到您选择的网址的最佳(正确,现代,跨浏览器,安全)方法是什么?
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 = '...';
如果您想要更改没有反映在浏览器后退历史记录中的页面,您可以执行以下操作: / p>
If you wanted to change the page without it reflecting in the browser back history, you can do:
window.location.replace('...');
这篇关于如何让浏览器在JavaScript中导航到URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文