PDA

View Full Version : How can I change URL without refreshing the page?



phpdeveloper
01-27-2011, 11:39 AM
My URL is: http://localhost/testproject/product.html#catId=155

I want to URL: http://localhost/testproject/product.html without refreshing the page.

Is this possible using javascript/jquery or not ?

oesxyl
01-27-2011, 11:41 AM
My URL is: http://localhost/testproject/product.html#catId=155

I want to URL: http://localhost/testproject/product.html without refreshing the page.

Is this possible using javascript/jquery or not ?
yes is possible, take a look after ajax.

best regards

Philip M
01-27-2011, 12:10 PM
Perhaps I have misunderstood, but it sounds a bit like "Can I change from one bus to another without boarding another bus?". I would have said that this was not possible.

venegal
01-27-2011, 12:33 PM
You're not really changing the URL, only the hash value. You can do this with

window.location.hash = 'whatever';

There won't be a page refresh.

Be advised, though, that setting the hash to an empty string, your URL still won't look like

http://localhost/testproject/product.html
but like

http://localhost/testproject/product.html#

oesxyl
01-27-2011, 01:06 PM
Perhaps I have misunderstood, but it sounds a bit like "Can I change from one bus to another without boarding another bus?". I would have said that this was not possible.
i don't know what op ask before but this look like changing the content of the page based on a catid value, as he said, usual stuff of a dynamic page. But if he want to be html, want to use javascript and don't want to refresh, look like he need ajax.

best regards

phpdeveloper
02-04-2011, 10:11 AM
yes is possible, take a look after ajax.

best regards

Can you give me idea or reference how can i do this.

oesxyl
02-04-2011, 10:33 AM
Can you give me idea or reference how can i do this.
i'm not sure if this will help you but probably you can make an idea:

http://www.ajaxtutorial.net/index.php/2006/11/29/simple-ajax-using-prototype-part-1/

best regards