homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Js that doesn't kill the back button

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

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) {

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



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

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)

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)

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.



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

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)

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.
  • tedster

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

    >> 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.

    Global Options:
     top home search open messages active posts  

    Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
    rss feed

    All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
    Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
    WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
    © Webmaster World 1996-2014 all rights reserved