|
[Pop-up script is provided in this article to boost your profits!]
A common use for a popup is to make it appear when the visitor exits the page. It can help to attract subscribers for example, or further promote a product.
However, if you are selling a product on your web page, and the visitor has pressed that most important 'Buy now!' button, the last thing you want to happen is for a popup to appear and distract them, or even worse annoy them in a way that loses you the sale. In fact in many cases, as you have now 'closed the sale', there may be little reason for the popup to... well, pop up. The disadvantages of using a popup at this particular marketing juncture certainly outweigh the usual advantages.
So, what if we want to keep our usual exit popup that we've found to be so effective, but prevent it from appearing when the user clicks to buy?
Let's look at the normal exit popup script you could use. This code should be installed between the head tags of your HTML document.
<SCRIPT LANGUAGE="JavaScript">
<!--begin
/*
* Popup code generated by PopUpMaster Pro from PopUpMaster.com
*/
function popup(filename){
window.open(filename, "","height=300,width=300,top=0,left=0,
location=no,menubar=no,resizable=yes,scrollbars=no,status=no,
titlebar=no,toolbar=no,directories=no");
}
// end -->
</SCRIPT>
Note that the line starting 'window.open' to the semi-colon ';' should be one continuous line with no carriage return - it is shown here on two lines for display purposes only.
To make the new window popup on exit, you simply add the following code to your body tag:
onUnload="popup('popup.html')"
Your body tag may therefore look like the following:
<body bgcolor="white" onUnload="popup('popup.html')">
Now comes the clever part where we add code to allow us to 'opt out' of the new window appearing on exit if certain circumstances exist, for example if the user clicks a 'Buy now!' button or similar.
We must first modify the main body of the JavaScript code that's shown above. Have a look at the following code, the changes are marked by comments in the code and I further explain them below.
<SCRIPT LANGUAGE="JavaScript">
<!--begin
/*
* Popup code generated by PopUpMaster Pro from PopUpMaster.com
*/
//### Set an exit variable to true ###
var exit = true;
function popup(filename){
//### Test the value of 'exit' before displaying the popup ###
if(exit){
window.open(filename, "","height=300,width=300,top=0,left=0,location=no,
menubar=no,resizable=yes,scrollbars=no,status=no,titlebar=no,toolbar=no,
directories=no");
} //### Close the test of the 'exit' variable
}
// end -->
</SCRIPT>
As you can see by this code, we have set a variable to true, and then test that this variable is still true before the new window is displayed. If the variable is not true, the popup will simply not appear.
To enable this, we need to then add code to all the links and buttons, where if the user clicks them we do *not* want the popup to appear. Other links and buttons we just leave well alone.
This is the code we need:
onclick="exit=false;"
This sets the value of the exit variable to false, so that when the test on the variable runs, it will fail and the new window will not appear.
We add this code to the relevant tags for buttons and links as follows.
Here's an example for a standard link:
<a href="purchase.html" onclick="exit=false;">Buy now!</a>
If you want to add the code to a button rather than a link, here's an example of how you should install the code:
<input type="button" value="Buy now!" onclick="exit=false;">
That's all there is to it. As always, make sure you test your web page before you upload it to your web site to make sure it works to your satisfaction.
Steve Shaw is the author of 'The PopUp Masters Course' - find out how to boost your opt-in subscriber rate 535% by signing up for the FREE course at http://takanomi.com/newsletter.
PopUpMaster Pro - creates popups that beat the popup blockers,
and sign up subscribers...FAST
|