我想在不重新加载页面的情况下更改浏览器栏中的URL.
<html><head>
<title>Change url in browser bar</title>
</head>
<body>
<h1>Refresh page to see our other website</h1>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
当任何用户进入我的网站,如www.a-site.com打开此网站后,他会看到文本 刷新页面,以查看我们的其他网站.我能做到这一点,当他在进入www.a-site.com,就像在浏览器栏这个网址变更后www.b-site.com当用户刷新页面可以automaticaaly重定向
www.b-site.com.这是可能的吗?
谢谢...............
und*_*ore 11
您正在寻找以下内容
window.history.pushState("object or string", "Title", "/new-url");
Run Code Online (Sandbox Code Playgroud)
这是我读过的原始文章(2012年7月10日发布):HTML5:更改浏览器URL而不刷新页面.
例:
function processAjaxData(response, urlPath){
document.getElementById("content").innerHTML = response.html;
document.title = response.pageTitle;
window.history.pushState({"html":response.html,"pageTitle":response.pageTitle},"", urlPath);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17064 次 |
| 最近记录: |