locationreplacehttpswwwygbxhebcnindex1html;改为locationhref = httpswwwygbxhebcnindex1html;后网址跳转后浏览器地址栏中的网址还是跳转后的新网址如果让它跳转后显示跳转前的网址用AI说的方法改为historyreplaceStatenull null httpswwwygbxhebcnindex1html;后就直接不跳
是的,使用history.replaceState方法可以在不跳转页面的情况下改变浏览器地址栏的网址。修改后的代码如下:
history.replaceState(null, null, "https://www.ygbxheb.cn/index1.html"); 这样,网页会保持在当前页面,但是浏览器地址栏中的网址会变为跳转后的新网址。
原文地址: https://www.cveoy.top/t/topic/h9yo 著作权归作者所有。请勿转载和采集!