Forum Moderators: open

Message Too Old, No Replies

Back Button Action Support

         

sobinbabue

9:06 pm on Jun 2, 2008 (gmt 0)

10+ Year Member



Hi All,

I need to disable the back button in IE browser for a particular php web page. Any one can help for that?

Alternate for above: is there any way to get the from page name when some one click the back button in IE?

penders

11:18 pm on Jun 2, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Not possible to literally disable the back button - a user will always be able to click it or hit [backspace]. It is a browser feature you can't alter from a webpage (and nor should you be able to).

However, you could 'break the back button' (a common, and often undesirable, fault of some AJAX apps). New content is dynamically loaded into the page (your PHP page for instance). It can look like an entirely new page to your user but no entry appears in the browser history - the back button is 'broken'. The back button is obviously still available but the user can't get back to the 'page' they were just on (at least the page they thought they were on).

Alternate for above: is there any way to get the from page name when some one click the back button in IE?

You can usually get the 'referer' (the page from which the user has come from - having possibly followed a link) when a user lands on a page:
JavaScript -

document.referrer

PHP -
$_SERVER['HTTP_REFERER']

However, when the user hits the back button I'm pretty sure the page is simply pulled from the cache, including the referer. So the referer does not show the page you have just moved back from, but the page the user came from in order to get to that page in the beginning (that is of course if it set at all). At least that seems to be the case when I've tried this from JS - it shouldn't (probably doesn't) cause a request back to the server?

May be you can track the last few pages your user visits in a cookie (breadcrumb) or something and constantly check the last visited page, on every page?!

IMHO there is no (easy) solution to this.

httpwebwitch

11:35 pm on Jun 2, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It may be worthwhile to examine why you want the "go back" abiliity disabled, and see if there isn't a better design pattern you can emulate. What exactly are you building?