Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
JavaScript
history.pushState(null, "", 'Account/'+Id);

it display something like that
Admin/Account/Account/Id

but i need url in this format Admin/Account/Id
can someone help

Thanks
Posted

1 solution

You are pushing a relative - to your current position - URL while writing this:
JavaScript
history.pushState(null, "", 'Account/'+Id);

You should remove 'Account'...
JavaScript
history.pushState(null, "", Id);

...or use absolute URL
JavaScript
history.pushState(null, "", '/Admin/Account/'+Id);
 
Share this answer
 
Comments
Vishal Pand3y 30-Apr-14 4:48am    
thanks @Kornfeld Eliyahu Peter for your reply using absolute url is working but I don't know how because i have tried history.pushState(null, "", Id);
its showing url like that Admin/Id

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900