如何覆盖URL

How to Overwrite the URL?

本文关键字:URL 覆盖 何覆盖      更新时间:2023-09-26

我有这个URL:

http://qwertyuiopasdfghjklczxcvbnm

我想在不改变页面的情况下将其更改为其他内容:

http://www.something.com

这可能吗?如果是,请告诉我代码

您需要使用pushState或replaceState方法

window.history.pushState(null, null, "/your-new-url");

window.history.replaceState(null, null, "/another-new-url");