更改网址而不回发 [英] Change url without postback
本文介绍了更改网址而不回发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的页面中我有一个锚点在那个锚点击我正在用ajax更新页面所以页面的url没有改变所以我用history.pushState来改变网址没有回发
我的网址是这样的
管理员/帐户/身份
现在当我使用
In my page i have a anchor on that anchor's click i am updating page with ajax so url of page is not changing so I have used history.pushState to change the url without postback
my url is something like that
Admin/Account/Id
now when I am using
history.pushState(null, "", 'Account/'+Id);
它显示类似的东西
管理员/帐户/帐户/ Id
但是我需要这种格式的网址管理员/帐户/身份证
有人可以帮助
谢谢
it display something like that
Admin/Account/Account/Id
but i need url in this format Admin/Account/Id
can someone help
Thanks
推荐答案
你正在写一个亲戚 - 你当前的位置 - 写这篇文章的URL:
You are pushing a relative - to your current position - URL while writing this:
history.pushState(null, "", 'Account/'+Id);
您应该删除帐户...
You should remove 'Account'...
history.pushState(null, "", Id);
...或使用绝对URL
...or use absolute URL
history.pushState(null, "", '/Admin/Account/'+Id);
这篇关于更改网址而不回发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文