且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无需重新加载现有页面即可更改浏览器地址栏中的 URL

更新时间:2023-08-31 22:24:34

这是一个类似的问题.

这是一个例子:

function processAjaxData(response, urlPath){
    document.getElementById("content").innerHTML = response.html;
    document.title = response.pageTitle;
    window.history.pushState(
        {
            "html":response.html,
            "pageTitle":response.pageTitle
        },
        "",
        urlPath
   );
}