Pop-under Scripts

pop-under scripts,popunder scripts,pop-under

Below you'll find a variety of pop-under scripts together with explanations of how the javascript code works.

Pop-under windows open underneath, or behind the front window. As pop-unders load in the background, visitors usually don't notice them until they close the front window. This gives the pop-under plenty of time to load, enabling you to put more content in the page.

The code for pop-under windows is not much different to that for regular pop-ups. In fact, it's identical except for a tiny addition which tells the browser the pop-under shouldn't be the front window.

In Javacript, if we give a window "focus" it is sent to the front. If we "blur" a window, it no longer has focus. We can use either focus or blur to create a pop-under window. We can give the main, or "trigger" window focus, thereby forcing the pop window behind it. Or we can directly blur the pop window itself, thus sending it to the back.


Using the focus() Method

Let's look at our second pop-up script example earlier. We could make a pop-under script from this by simply adding the window.focus() method (the new code is underlined):

<script language="javascript">
<!-- begin

function popup(){
window.open('URL/to/popup.html','PopupName','toolbar=0,
location=0,status=0,menubar=0,scrollbars=0,resizable=0,
width=345,height=400');
window.focus();
}

// end -->
</script>

The window.focus() instruction acts on the current window. Thus as soon as the pop window opens, the trigger window will push itself back to the front.

Note: This script and all the examples below are called using the onLoad="popup()" command inserted in the <BODY> tag


Another way we could achieve the same result is by adding:

onblur=self.focus()

To the <BODY> tag on the trigger page. What this does is basically tell the page "If you loose the front position (onblur), put yourself back in front (self.focus)." When the page regains focus, it therefore pushes the pop window behind it.



Using the blur() Method

To tell the pop window itself to blur, the JavaScript needs to be able to reference the new window. To do that we need to assign a variable (var) to it which we'll call "newWindow" like this:

<script language="javascript">
<!-- begin

function popup() {
var newWindow = window.open('URL/to/popup.html','PopupName',
'toolbar=0,location=0,status=0,menubar=0,scrollbars=0,
resizable=0,width=345,height=400');
newWindow.blur();
}

// end -->
</script>

As you can see, the last line now calls the blur() method on the pop window with:

newWindow.blur();


A tidier way to do the same is to use the third pop-up example we gave. Since the variable "newWindow" is already defined in this script, all we need to do is add newWindow.blur() to the code:

<script language="javascript">
<!-- begin

function popup() {
var page = "URL/to/popup.html";
var windowprops = "width=380,height=500,location=no,menubar=no,
toolbar=no,scrollbars=no,resizable=no";
newWindow = window.open(page,'PopupName',windowprops);
newWindow.blur();
}

// end -->
</script>


To employ the blur() method with the cookie script you need to modify it by defining our "newWindow" variable like this:

function checkCount() {
var count = GetCookie('count');
if (count == null) {
count=1;
SetCookie('count', count, exp);
newWindow = window.open(page, "PopupName", windowprops);
newWindow.blur();

 

Confused? Use an Automatic PopUp Generator instead

 

[Pop-up Windows] [Using Pop-up Ads] [Pop-up Scripts] [Exit Pop-ups] [Cookie Pop-ups]

[Pop-under Windows] [Pop-under Scripts] [Pop-up Maker] [Pop-Up Software]