views:

304

answers:

4

hi im using ajax to extract all the pages into the main page but am not being able to control the refresh , if somebody refreshes the page returns back to the main page can anybody give me any solutions , i would really appreciate the help...

A: 

You can rewrite the current url so it gives pointers to where the user was - see Facebook for examples of this.

ck
thanks will check out ;)
+2  A: 

you could add anchor (#something) to your URL and change it to something you can decode to some particular page state on every ajax event.

then in body.onload check the anchor and decode it to some state.

back button (at least in firefox) will be working alright too. if you want back button to work in ie6, you should add some iframe magic.

check various javascript libraries designed to support back button or history in ajax environment - this is probably what you really need. for example, jQuery history plugin

miceuz
thanks for the answer will check out jquery too ;)
you should definately check our jQuery if you are going to realt of javascript. very handy to use, but not much helpful in terms of learning javascript in depth..
miceuz
A: 

I always store the 'current' state in PHP session.

So, user can refresh at any time and page will still be the same.

Milan Babuškov
A: 

if somebody refreshes the page returns back to the main page can anybody give me any solutions

This is a feature, not a bug in the browser. You need to change the URL for different pages. Nothing is worse then websites that use any kind of magic either on the client side or the server side which causes a bunch of completely different pages to use the same URL. Why? How the heck am I gonna link to a specific page? What if I like something and want to copy & paste the URL into an IM window?

In other words, consider the use cases. What constitutes a "page"? For example, if you have a website for stock quotes--should each stock have a unique URL? Yes. Should you have a unique URL for every variation you can make to the graph (i.e. logarithmic vs linear, etc)? Depends--if you dont, at least provide a "share this" like google maps does so you can have some kind of URL that you can share.

That all said, I agree with the suggestion to mess with the #anchor and parse it out. Probably the most elegant solution.

Cory R. King