如何从JavaScript中更改页面 [英] How to change page from within JavaScript
本文介绍了如何从JavaScript中更改页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码在JavaScript中更改页面:
I have the following code that changes the pages from within JavaScript:
var newUrl = [some code to build up URL string];
window.location.replace(newUrl);
但它不会更改顶部网址,所以当有人点击后退按钮时它不会返回上一页。
But it doesn't change the top URL, so when someone clicks the back button it doesn't go back to the previous page.
我如何让JavaScript更改顶部URL,以便浏览器后退按钮正常工作。
How can I have JavaScript change the top URL as well so the browser back button works.
推荐答案
document.location.href = newUrl;
https://developer.mozilla.org/en-US/docs/Web/API/document.location
这篇关于如何从JavaScript中更改页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文