【发布时间】:2012-06-01 02:51:09
【问题描述】:
可能重复:
Change the URL in the browser without loading the new page using JavaScript
我只想在浏览器地址栏中添加网址Note: dont want redirect
e.i 我有一个网址www.example.com/index.html
我想在“地址栏”上设置网址,例如www.example.com/index/page2.html
我使用document.location.hash = 'foo';
but it is add only # data
like www.example.com/index.html#foo
note : i dont want to redirect only want to add url in address bar so don't answer document.location like that
有什么解决办法吗?
【问题讨论】:
-
你不能这样做,这是出于安全原因。
-
请查看此处发布的链接。两者都描述了如何做到这一点。安全问题限制您将其设置为另一个 url,但您可以使用历史 API 更改路径。
-
@chucktator 他能做的最好的事情就是来自他的例子是
www.example.com/index.html/page2.html -
有可能看到这个博客并点击任何帖子标题然后它是在浏览器地址栏中的变化看到这个freesubmiturlindia.blogspot.in
标签: java javascript jquery