///Presenting a “Good-bye” Message Without Popups Using JavaScript

Presenting a “Good-bye” Message Without Popups Using JavaScript

Presenting a “Good-bye” Message Without Popups

The proliferation of popup blockers and ad removal software has eroded those income producing methods for many web site publishers. And it’s only getting worse.

Popup boxes of information that pop up over the contents of a page (part of the page, not in a separate window) are also being targeted by “blocking” software.

Here is a method that can be used to present a final web page, a “good-bye” page, to site visitors after they click on a link to a page on another (or your own) web site.

When a link is clicked, the new page opens in a new window (or in a new tab). Immediately after the new window opens, the original window or tab loads the good-bye page.

The visitor now has a window or tab with the new page, and also one with the good-bye page. The good-bye page might contain messages such as an invitation to subscribe, to buy, to take a survey, or simply to convey best wishes for the visitor’s continued health and happiness.

No popup is required.

The new window or tab contains the web page the visitor asked for.

The old window or tab silently loads another web page in the background.

Here’s how to implement it.

The JavaScript In the HEAD Area

Put this JavaScript in the HEAD area of the web page source code:

<script type="text/javascript" language="JavaScript">

<!-- Copyright 2005 Bontrager Connection, LLC
// See "Presenting a 'good-bye' Message Without Popups" at
// http://willmaster.com/possibilities/ for useful info.
// (keep copyright notice and resource info with script)
// Specify the URL of the web page that shall be loaded
// into the old window or tab when the visitor a
// specific link. Put the URL on the next line, between
// the quotation marks.
var OldWindowDestination = "http://LightFocus.com/";

// Specify the number of milliseconds to wait after the
// click before the above URL is loaded into the old
// window or tab. Recommend 250 minimum to give browser
// a chance to complete launching the new window. Put
// the number on the next line, between the quotation
// marks.
var NumberOfMillisecondsToWait = "1000";

// No further customization is necessary.

function Dest() { location.href = OldWindowDestination; }
function NewURL() {
return true;

You’ll notice two places to customize in the above script.

1. A place to provide the URL of the good-bye page for display in the old window or tab. This can be any valid URL.

2. The number of milliseconds to wait after the visitor clicks the link before loading the good bye page in the old window or tab. The delay is to allow the new window or tab to be created first.

The above JavaScript specifies 1000 milliseconds. I recommend no less than 250 milliseconds because with slow browsers, or browsers running on very busy machines, it may take as much as a quarter second to create the new window or tab.

The Attributes In the Anchor (Link) Tag

Two attributes need to be in the anchor tag. The links will then:

Open a new window or tab with the web page at the URL of the link that was clicked.

Cause a good-bye page to be loaded in the old window or tab.

These are the two attributes:


onclick=”return NewURL();”

The target=”_blank” attribute causes a new window or tab to open, within which loads the URL of the link.

The onclick=”return NewURL();” attribute causes the good-bye page to load in the old window or tab.

Here is an example anchor tag:


onclick="return NewURL();"
Click to try

Try It

Make a web page with the JavaScript in the HEAD area and the anchor tag in the BODY area. Then click on the link. For the test, you don’t have to change any of the code, just copy and paste.

You’ll see how it works.

A note abut tab browsing:

It’s a joy.

Firefox from http://www.mozilla.org/products/firefox/ and Opera from http://www.opera.com/ both offer the tabbed browsing experience.

Firefox launches a new window when the target=”_blank” attribute is encountered, unless the Tabbrowser Preferences extension is installed and set to open a new tab instead.

Opera opens a new tab automatically, not a new window.

2010-05-26T11:42:01+00:00 March 29th, 2005|JavaScript|0 Comments

About the Author:

Leave A Comment