Results 1 to 3 of 3

Thread: Browser Back Button Control

  1. #1
    Join Date
    Feb 2006
    Posts
    236
    Thanks
    8
    Thanked 3 Times in 3 Posts

    Default Browser Back Button Control

    I need to control the back button - browser history, so when in page2, it goes back to page1, and when in page3 it goes back to page1. (Gotta avoid $_POST a second time in page2). The catch is that page two is not always in the sequence because of a cookie check.

    I think it will be allright to make the browser history for page2 = page1 (falsifying the entry). How can I control the browser history?

    I've been fighting this problem for almost month, thought it was other things for a while, learned a lot, but just never enough (yet).

    ~~~~ (new edit)

    Just found some code on DD (a Marquee script discussion) that gave me a hint, so I'm now thinking, is this the right way to go? Will it work correctly in all browsers? How about even IE? I found a lot of garbled (to me) discussions of banned sites using this too?
    Code:
    <?php
    
    function _begin_html()
    {
      ?>
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
      <html>
      <head>
        <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
        <link rel="STYLESHEET" type="text/css" href="lib/style.css">
        <title>Password Login ver 0.0.2</title>
    	<script language="javascript1.1">
    	  <!--
    	    window.location.replace('http://earth.ccny.cuny.edu/noaa/wc.html');
    	  //-->
    	</script>
    	<script language="javascript">
    	  <!--
    	    window.location.href = "http://earth.ccny.cuny.edu/noaa/wc.html";
    	  //-->
    	</script>
      </head>
      <body>
      <?
    }
    Last edited by Strangeplant; 07-13-2006 at 02:42 PM.

  2. #2
    Join Date
    Feb 2006
    Posts
    236
    Thanks
    8
    Thanked 3 Times in 3 Posts

    Default

    I tried this out, and found that it does rewrite the history for the page it's in, AND (this is the part that doesn't work for me) immediately takes me to that page. So, history is rewritten AND simultaneously invoked.

    Bad, is there any way around this?

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Browser history is protected from most manipulations. All you can do is prevent a page from being added to the stack and replace a page's position in the stack. But, if a user is navigating primarily with their back and forward buttons, or has javascript disabled, even these methods cannot be relied upon. I didn't look at all your code above because there really is no javascript solution to this. You will need a server side solution to the problem, probably one not using history but, rather a session variable or some such thing, server side is not my strong point though.

    What kind of server side language are you using to process your form? Post your problem in the forum dedicated to that language. I'd suggest using that language to create a session variable that redirects away from the page you don't want loaded a second time if it has already been visited. Those more familiar with server side coding may have a better idea.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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