Click here to Skip to main content
15,890,436 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I want to update browser url without page being submitted.The URL can be anything, like xyz..Please help me.Thanks in advance.

This is what i have done so far.
JavaScript
//            if (history.pushState) {
//                // The first is an object that you will use to identify the history entry later, the second is referred to as the 'title' parameter
//                //The final parameter is the URL you want to link the new state to. This doesn't have to exist on the server, and it can be relative or absolute, however, 
//                //as with AJAX, you cannot use a domain other than the current one. 
//                window.history.pushState({ "html": response.html, "pageTitle": response.pageTitle }, "", urlPath);
//            }
//            else {
//                window.location.pathname = urlPath;
//                // window.history.pushState({ "html": response.html, "pageTitle": response.pageTitle }, "", urlPath);
//            }


But the page reloads by using this. Why ? can anyone help me
Posted
Updated 2-Jan-14 21:52pm
v3
Comments
Richard MacCutchan 3-Jan-14 4:15am    
Maybe because all the actual code is commented out.
Arjun Menon U.K 3-Jan-14 5:19am    
When i uncomment the code above, refresh happens
Sandeep Mewara 3-Jan-14 4:57am    
I doubt if you can change the URL without page submit.
Arjun Menon U.K 3-Jan-14 5:25am    
according to this article, pushstate wont refresh page
http://spoiledmilk.com/blog/html5-changing-the-browser-url-without-refreshing-page/#comment-6552

1 solution

So essentially you are trying to construct a page that will, after it has been loaded, show a completely different URL than the one the page was originally loaded from? Should this be the case then it sounds very suspicious to me as it seems like an attempt of a spoofing attack[^].
Please tell us in more detail what it is you're actually trying to do.

If this turns out to be an attempt at hacking, you'll have no luck here on CP as we don't support this kind of behaviour.

Regards,
— Manfred
 
Share this answer
 
v3
Comments
Manfred Rudolf Bihy 3-Jan-14 4:36am    
Thanks @thatraja, for fixing the link. I've no idea how that got fouled up.
Arjun Menon U.K 3-Jan-14 5:18am    
Hi Manfred R. Bihy,
No actually what i need to do is to update a browser url, so that the actual url will not get displayed. Since the request is AJAX, it wont be reflected in the browser url, that's y am asking this.

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