Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Creating a pop-under Window

0.00/5 (No votes)
26 Dec 2001 1  
This tutorial shows you how to create a popunder window using JavaScript

Introduction

I feel guilty writing this tutorial, but as the saying goes, "give people what they want", or to be more precise, developers. A lot of developers would like to know how to implement pop-under windows on their site as a way to broadcast advertising. Yes, it's annoying for the visitor, but proven quite effective in getting attention.

Creating a pop-under window is very simple, by using JavaScript. Basically, one would use the same method for creating a popup window, but then "un-focus" it. Here is the code in full force:

<script>
win2=window.open("http://www.msn.com")
win2.blur()
window.focus()
</script>

That's it! I open a window by invoking window.open(), blur it, then redirect the focus to the main window instead. Translation - the popup window becomes a pop-under instead.

You've probably seen more sophisticated pop-under scripts that control the "frequency" of the pop-under, such as popping up only once per browser session. Instead of reinventing the wheel, I'll simply point you to a nice example of this on JavaScript Kit: http://javascriptkit.com/script/script2/popunder.shtml

Have fun with popping under your windows.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here