Results 1 to 7 of 7

Thread: catch back button in web browser

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2005
    Location
    Manila, Philippines
    Posts
    486

    catch back button in web browser

    Hi guys,

    Is there a way to catch the back button in web browser?
    Let's say a user logs in then he goes to the viewdata.aspx after which he then goes back to the main page and logs out.
    What i want now is whenever he hits the back button he will then be redirected to the login.aspx.
    I tried using sessions and it works if only the user types in the url but if hits the back button he can still view the cached data.
    I don't want to disable the caching of my webforms since it (i think) i slows the web page and also because it prevents the user to view data that is being cached since the user is still log on.

    Thanks and God bless

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: catch back button in web browser

    It doesn't "slow" the web page, it will make sure that the page is loaded from the server each time, but the difference is minimal, as that is the right solution. This way as long as the user is logged in, he can view what's on viewdata.aspx.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2005
    Location
    Manila, Philippines
    Posts
    486

    Re: catch back button in web browser

    Actually the user can not view the page that he visited whenever i disable the caching. it automatically expires whenever the user hits the back button eventhough he is still log in. I just like to trap the back button or the forward button, everything else is ok since i am using session. i only disable the caching part on the pages that requires update and insert since these pages requires click event to process transactions. Thanks

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: catch back button in web browser

    You can introduce a "Thank you for submitting that information" page which does a javascript location.replace so that when the user clicks back, he ends up on the thank-you page which redirects him forward anyways.

    You can't really 'catch' a back button event as it is a browser event, not a server side one.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2005
    Location
    Manila, Philippines
    Posts
    486

    Re: catch back button in web browser

    but can i have little sample.
    Thanks

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: catch back button in web browser

    Is what I've described really that difficult? Can you at least perform a few searches and find some code that you try to put together? (And show us where you're stuck)

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2005
    Location
    Manila, Philippines
    Posts
    486

    Re: catch back button in web browser

    Quote Originally Posted by mendhak
    Can you at least perform a few searches and find some code that you try to put together? (And show us where you're stuck)
    that's why maybe i'm here to do a research. thanks anyway

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width