views:

69

answers:

2

Hi,

I would like to know if its possible to change the contents of the URL in the browser without reloading the page. I use jQuery and Ajax to load new parts of my page. When I choose product one, the direct link would be "mysite.com/product1" and product two "mysite.com/product2", but I don't want to reload the site to these pages.

Best regards, Paul Peelen

+3  A: 

You will have to add hash # if you want to prevent page from reloading.

The css-tricks.com has an excellent screencast on that, have a look at:

Best Practices with Dynamic Content

Sarfraz
A: 

You can't. Only if you change the hash, like sAc told you.

But.. May I ask WHY?

Ionut Staicu
I'm not the OP, but I find it useful when you change your content via ajax, and then your visitor wants to store the page he is looking at to bookmarks/send via email/ etc..
Yossarian
Like Yossarian said, that was one of my reasons. Also because the load of the page loading is less using ajax, and the loading of contens is better looking.
Paul Peelen
@Yossarian: I asked why he wants to use site.com/product, like the initial Q was (not hash).@Paul: if you change more than 4-50% of your page content, you may want to rethink your strategy, because the speed you will gain with page transfer will be canceled by the DOM operation time :)
Ionut Staicu