Place your message here

Your Guide to Professional
Web Site Design and Development

Web Development
HTML Codes
HTML Tips
Javascript Snippets
216 Safe Colors
Symbols
Web Directory
Web Resources
Internet Channels

Web Development: Business, Advertising, Internet Marketing, Promotion and Web Site Design

| Web Development | HTML Codes | HTML Tips | Javascript Snippets | 216 Safe Colors | Symbols | Recommendations |

No-Kill Pop Box; Part III

By William Bontrager

This article provides the means to use cookies so your No-Kill Pop Box is displayed only once to a visitor for a pre-determined number of days.

     Part 1. "No-Kill Pop Box (Instead of Popups)"

        The basic code for creating a Pop Box.

     Part 2. "No-Kill Pop Box; Part II"

        Comparisons with focus on differences of the No-Kill
        Pop Box and Pop-ups/unders. Code for delayed opening
        of the No-Kill Pop Box and to open and close the
        No-Kill Pop Box with links.

The demo page contains the complete code necessary to implement the No-Kill Pop Box with cookies.

If you haven't read the other two articles in this series, I urge you to do so now. Unless you are a proficient JavaScript programmer, the rest of this article may make little sense until familiarity with the other two articles is attained.

The global variable and functions that were added since the second of this article series are:

     1. A global variable named DaysToLive

        Here, specify the number of days you want the
        cookie to live, a maximum of 3652 days, representing
        10 years. If you want the cookie to disappear when
        the browser is closed (called "session cookies"),
        specify 0 (zero) days.

     2. Function SetCookie()

        This is the function that sets the cookie when the
        No-Kill Pop Box is displayed.

     3. Function GetCookie()

        This function is used to determine whether or not
        the cookie exists in the browser.

     4. Function OpenPopBoxIfOkay()

        This function is called when a page first loads. It
        uses function GetCookie() to determine whether or
        not the No-Kill Pop Box should be displayed.

        Function OpenPopBoxIfOkay() must be called or the
        No-Kill Pop Box won't ever be displayed and no
        cookie will be set. The function can be called
        using any of the following methods:

          i. In the BODY tag itself with

onLoad="OpenPopBoxIfOkay()"

             Example:

<BODY onLoad="OpenPopBoxIfOkay()">

             The above calls the function as soon as the
             page completes loading.

         ii. Somewhere in the BODY area with

<script type="text/javascript" language="JavaScript"><!--
OpenPopBoxIfOkay();
//--></script>

             The above calls the function when the browser
             loads the code.

        iii. Somewhere in the BODY area with

<script type="text/javascript" language="JavaScript"><!--
setTimeout('OpenPopBoxIfOkay()',3000);
//--></script>

             The above calls the function 3 seconds after
             the browser loads the code. The number 3000
             in the above codes represents 3000 milliseconds
             delay. Adjust that number as appropriate for
             your installation.

You'll notice that the demonstration for this article contains a WillMaster Possibilities subscription form.

When a form is put into the No-Kill Pop Box and the form submitted, the "thank you" page will be a new page, like it would be if the form was submitted from a normal page -- the "thank you" page will not display inside the No-Kill Pop Box.

Because the No-Kill Pop Box is displayed only the one time, the "thank you" page can be the same page the form was submitted from. When the "thank you" page loads, the No-Kill Pop Box won't display because it has already been displayed once. In effect, the form user is sent to the same page the form was submitted from -- except the page no longer displays the form.

Note: Browsers with cookies disabled, will show the form
      every time the page loads. (I've never done a survey
      to determine how many cookies-disabled browsers visit
      our sites. I'm thinking the number is low, but I
      can't be certain.)

The first three parts of this series have provided the code necessary to use No-Kill Pop Boxes in a professional manner.

Will Bontrager

About the Author:

William Bontrager Programmer/Publisher, "WillMaster Possibilities" ezine mailto:possibilities@willmaster.com

Are you looking for top quality scripts? Visit Willmaster and check out his highly acclaimed Master Series scripts. Some free, some for a fee.

Back