开发者

Change URL basename

开发者 https://www.devze.com 2023-01-28 16:16 出处:网络
I\'m using AJAX to display a transition betwee开发者_JAVA技巧n pages and I\'d like to change the URL basename when the user clicks on a link. I\'m using PHP to be able to use URLs like mydomain.com/my

I'm using AJAX to display a transition betwee开发者_JAVA技巧n pages and I'd like to change the URL basename when the user clicks on a link. I'm using PHP to be able to use URLs like mydomain.com/mypage, so I'd like to be able to change "mypage" to something else like "mysecondpage". How may I do that?


You can use history.pushState, but it is firefox-only. The standard way to do it is by using different hashes (e.g. mydomain.com/#mypage --> mydomain.com/#mysecondpage). This can be done simply by changing window.location.hash.


You can't, unless you use a hash #likethis.

0

精彩评论

暂无评论...
验证码 换一张
取 消