Browser "Back" fails after javascript redirect?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Simon Wigzell

    #1

    Browser "Back" fails after javascript redirect?

    I'm using :

    window.location .href = [newUrl]

    to redirect to a web page. From the new webpage, when you click the browser
    "Back" button you of course end up on the same old page and get redirected
    immediately to the new page. Apart from double clicking really fast (!) or
    putting in a delay with the old "Your browser will be redirect in 5
    seconds...blah blah blah" is there some other way of handling this? e.g. if
    the first page could be aware that it has been reached with a "Back" button
    and then perform a "Back" of it's own, then I'd be happy. Any other way of
    handling this situation? Thanks!



  • Lee

    #2
    Re: Browser "Back&quot ; fails after javascript redirect?

    Simon Wigzell said:[color=blue]
    >
    >I'm using :
    >
    >window.locatio n.href = [newUrl]
    >
    >to redirect to a web page. From the new webpage, when you click the browser
    >"Back" button you of course end up on the same old page and get redirected
    >immediately to the new page.[/color]

    window.location .replace(newUrl );

    will replace the current page with the new page in the
    browser's history, so hitting BACK will take you to the
    previous page, instead.

    Comment

    • Simon Wigzell

      #3
      Re: Browser "Back&quot ; fails after javascript redirect?

      Dohhhh! (Slapping forehead)

      Talk about making a mountain out of a molehill! Thanks!



      Lee <REM0VElbspamtr ap@cox.net> wrote in message
      news:blfu8u02k9 o@drn.newsguy.c om...[color=blue]
      > Simon Wigzell said:[color=green]
      > >
      > >I'm using :
      > >
      > >window.locatio n.href = [newUrl]
      > >
      > >to redirect to a web page. From the new webpage, when you click the[/color][/color]
      browser[color=blue][color=green]
      > >"Back" button you of course end up on the same old page and get[/color][/color]
      redirected[color=blue][color=green]
      > >immediately to the new page.[/color]
      >
      > window.location .replace(newUrl );
      >
      > will replace the current page with the new page in the
      > browser's history, so hitting BACK will take you to the
      > previous page, instead.
      >[/color]


      Comment

      • Lasse Reichstein Nielsen

        #4
        Re: Browser &quot;Back&quot ; fails after javascript redirect?

        "Simon Wigzell" <simonwigzell@s haw.ca> writes:
        [color=blue]
        > I'm using :
        >
        > window.location .href = [newUrl]
        >
        > to redirect to a web page. From the new webpage, when you click the browser
        > "Back" button you of course end up on the same old page and get redirected
        > immediately to the new page. Apart from double clicking really fast (!) or
        > putting in a delay with the old "Your browser will be redirect in 5
        > seconds...blah blah blah" is there some other way of handling this?[/color]

        location.replac e([newUrl]);

        This replaces the current page in the history instead of just pushing
        the new page. The redirect page is no longer there to go back to.

        /L
        --
        Lasse Reichstein Nielsen - lrn@hotpop.com
        Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
        'Faith without judgement merely degrades the spirit divine.'

        Comment

        Working...