article

Creating a popunder window

Email
Submitted on: 1/2/2015 6:53:00 PM
By: Mike Thompson (from psc cd)  
Level: Intermediate
User Rating: By 4 Users
Compatibility:
Views: 1794
 
     My article shows you how to create a popunder window using scripting.

 
				

Creating a popunder window

I feel guilty writing this tutorial, but as the saying goes, "give the people what they want", or to be more precise, developers. A lot of developers would like to know how to implement popunder 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 popunder window is very simple, by using Javascript. Basically one would use the same method for creating a popup window, but then "unfocus" 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 popunder instead.

You can even customize the pop under window so certain standard features are removed, like the toolbar, or configure the window's size. Here's an example of each:

<script>
win2=window.open("http://www.msn.com","",toolbar=0)
win2.blur()
window.focus()
</script>
<script>
win2=window.open("http://www.msn.com","","width=500,height=250")
win2.blur()
window.focus()
</script>

You've probably seen more sophisticated popunder scripts that control the "frequency" of the popunder, 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.


Other 2 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Intermediate category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
 

To post feedback, first please login.