Welcome to WebmasterWorld Guest from 23.22.19.253

Forum Moderators: open

Message Too Old, No Replies

Js that doesn't kill the back button

   
5:10 pm on Jun 20, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm currently using this to replace the window with the frame if the page is pulled up outside of the frameset:

if(top==self) {
self.location.href='index.htm';}

Is there a code that doesn't disable the back button?

7:22 pm on Jun 20, 2001 (gmt 0)

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Yes, there is. Try:

if (parent==self) location.replace("URL");

It replaces the last entry in the history list, instead of creating a new one.

7:48 pm on Jun 20, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



tedster rocks!

I thank you and I'm sure I will have many less irritated visitors who try to return to the serps but most of all my log files thank you because now there won't be 400 entries from the clickety-click-click-clickety-click routine of trying to get free.

8:31 pm on Jun 20, 2001 (gmt 0)

10+ Year Member



Same question as toolman but without the frames . . . been trying to work this out for 2 days on my own.

I want to redirect old product pages. In the Head of the old page, I am using <SCRIPT SRC="/JS/2001.js"></SCRIPT> to point to the external javascript.

The external "/JS/2001.js" is simply window.location.replace("http://www.mydomain.com/newpage.html");

The redirection works perfectly but the Back Button on the newpage.html loops the user. I have tried <INPUT TYPE="button" VALUE="Go Back" ONCLICK="history.back(3)" NAME="button"> and <a href="javascript:history.back(2 and 3)">back</a>, but the loop continues.

I can't imagine disabling someone's Back Button.

Thanks.

9:31 pm on Jun 20, 2001 (gmt 0)

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



I suspect something else is at work here. Your javascript looks fine to me and I can't see how it creates a backbutton loop, unless the prior page also has a redirect. Do you have this kind of situation?

By the way, the safest way to create a link to an external js file is:

<script type="text/javascript" language="JavaScript" src="file.js"></script>

What you have is a bit too barebones to be sure of it working on all browsers.

10:04 pm on Jun 20, 2001 (gmt 0)

10+ Year Member



The safe way you pointed out works.

Many of my old product pages do well for some useful kw searches and I would hate to lose this traffic as I present a new line. Please check my thinking here: With this method, I can keep the "old" pages up for their keyword value, yet still direct the searcher to my new product line in a seamless, fair and safe way. I htaccess-protect my JS folder and I have not performed any trickery on the searcher nor flagged myself to the SEs.

And this, the scripting I described earlier plus your kind response, is the easiest and safest of redirection methods. Correct?

  • My furrowed brow thanks you,
  • My fingernails thank you,
  • My blood pressure thanks you
  • and I thank you.
  • 10:41 pm on Jun 20, 2001 (gmt 0)

    WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



    >> And this, the scripting I described earlier plus your kind response, is the easiest and safest of redirection methods. Correct? <<

    For now. As far as I know.

    It is, after all, a way of feeding a spider something different from what the average user will see, and that is Google kindly calls Search Engine Persuasion (SEP) or more unkindly, SPAM. But for now, search engines won't risk automatically running everyone's JavaScript just to check, so this is a relatively safe redirect method.

    However, if someone complains, you don't really have much of a defense against human review, except to say that visitors with no javascript can still see the original page. Keeping that back button working is a big step toward avoiding the complaints.