如何获得浏览器导航到URL的Javascript? [英] How to get browser to navigate to URL in Javascript?

查看:181
本文介绍了如何获得浏览器导航到URL的Javascript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是最好的(正确的,现代的,跨浏览器,安全)的方式来获得一个Web浏览器导航至您选择使用Javascript?

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?

推荐答案

这个工程在所有浏览器:

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('...');

这篇关于如何获得浏览器导航到URL的Javascript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆