我想知道如何在jQuery 中将页面URL 从example.com/file1.html?i=1
更改为example.com/file1.html
, 更改页面内容或重新加载页面。
答案 0 :(得分:0)
将更改URL而无需重定向或重新加载到file1.html。如果历史记录推送状态不可用,请使用替代方法。
if (history.pushState) {
window.history.pushState("{ Object }", "Title", "file1.html");
} else {
document.location.href = "file1.html";
}
功能
function Change(domain, title) {
let url = domain + 'file1.html';
window.history.pushState('data', `{$title}`, url);
document.title = title;
}