Click here to Skip to main content
15,886,873 members
Articles / Programming Languages / Javascript

Creating a pop-under Window

Rate me:
Please Sign up or sign in to vote.
2.28/5 (15 votes)
26 Dec 2001CPOL 199.1K   38   25
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:

JavaScript
<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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
SuggestionUnblockable popunder Pin
Member 1009963515-Jul-14 12:32
Member 1009963515-Jul-14 12:32 
GeneralCute Cool Pop-Ups Pin
ravindu_d15-Aug-07 15:59
ravindu_d15-Aug-07 15:59 
GeneralPopUnder arent always bad Pin
Seth Illgard8-Feb-07 17:06
Seth Illgard8-Feb-07 17:06 
Generalalert box in javascript Pin
PrakashBhaskar16-Jun-06 2:42
PrakashBhaskar16-Jun-06 2:42 
GeneralRe: alert box in javascript Pin
JeevaBharathi15-May-07 23:33
JeevaBharathi15-May-07 23:33 
Generalpopup - very urgent Pin
deulu31-Oct-05 20:49
deulu31-Oct-05 20:49 
GeneralRe: popup - very urgent Pin
wuxsh18-Jan-06 13:33
wuxsh18-Jan-06 13:33 
GeneralRe: popup - very urgent Pin
ravindu_d15-Aug-07 14:00
ravindu_d15-Aug-07 14:00 
GeneralSome Good Resources Pin
Anonymous19-Aug-05 17:33
Anonymous19-Aug-05 17:33 
GeneralRe: Some Good Resources Pin
ravindu_d15-Aug-07 14:14
ravindu_d15-Aug-07 14:14 
GeneralPopup window issues... Pin
BBWS1O6-Jun-05 9:54
BBWS1O6-Jun-05 9:54 
Here's a weird one: Cry | :((

I have an ASP.NET application (written in VB.NET), that uses a report created with MS Access. The client had some very nice, well-designed reports they built with Access, but they wanted the whole app to run on the web. So I spent weeks figuring out how to get an properly formatted Access report onto a web page; I found some bits and pieces here and there on various web sites and a few genius programmers pointed out some ways this could be done--quite a hack, and not at al clearly documented anywhere by Microsoft, that I'm aware of...but I got it to work. It requires the Microsoft Office XP Interop calls (OXPPIA), ADODB, etc. (Yay! E-mail me if you want the source code I used.)

So now here's what I do: I create a new query for a given customer, replace the report's recordsource with the new querydef, then have Access generate the report and export it to XML.

Access itself creates the ASP page, XML file, XSD file, etc, when you call its built-in ExportXML function, so I don't have any control over the code actually in the ASP file it creates.

The problem: Almost every time someone runs this, they get the previously generated report data, until they hit Refresh on their browser. Anyone have any ideas how to "force" the page to be displayed accurately every time without the user doing anything? Confused | :confused:

AND ANOTHER THING...

Anyone know how to make some kind of "Stand by..." progress or status screen display while the report is being cranked out? It can take several seconds and meanwhile the user has no idea anything is going on. I tried by having the "Create Report" button first open another window with Javascript, but that window or message doesn't display until the line that actually executes the report generation routine has been called and finished running. So the report pops up at the same time as the "Please wait..." message, which is pretty pointless! D'Oh! | :doh:

Any suggestions would be very much appreciated! Poke tongue | ;-P Big Grin | :-D

--------------------------------
From: Brian Battles WS1O

Rocky Hill, CT USA

BrianB@BattlesZone.com
www.BrianBattles.com

GeneralRe: Popup window issues... Pin
Brad Frere17-Jan-07 11:14
Brad Frere17-Jan-07 11:14 
Generalclose window Pin
yonghui1-Apr-04 16:10
yonghui1-Apr-04 16:10 
GeneralRe: close window Pin
Anonymous3-May-04 2:36
Anonymous3-May-04 2:36 
GeneralRe: close window Pin
ravindu_d15-Aug-07 14:11
ravindu_d15-Aug-07 14:11 
GeneralCode snippet Pin
alex.barylski29-Jan-04 18:20
alex.barylski29-Jan-04 18:20 
QuestionHow to develop a deeptree bar? Pin
W. Cheung22-May-03 18:48
W. Cheung22-May-03 18:48 
AnswerRe: How to develop a deeptree bar? Pin
ravindu_d15-Aug-07 14:23
ravindu_d15-Aug-07 14:23 
GeneralPopup window Pin
Quintonvz24-Apr-03 1:48
Quintonvz24-Apr-03 1:48 
GeneralPop-up Window Eliminator Pin
cpan200019-Jul-02 3:06
cpan200019-Jul-02 3:06 
Questionan unpopular topic eh? Pin
Nish Nishant28-Dec-01 19:34
sitebuilderNish Nishant28-Dec-01 19:34 
AnswerRe: an unpopular topic eh? Pin
Jörgen Sigvardsson7-Oct-02 20:34
Jörgen Sigvardsson7-Oct-02 20:34 
GeneralRe: an unpopular topic eh? Pin
Anonymous12-Feb-04 8:46
Anonymous12-Feb-04 8:46 
GeneralRe: an unpopular topic eh? Pin
Jörgen Sigvardsson12-Feb-04 9:25
Jörgen Sigvardsson12-Feb-04 9:25 
GeneralRe: an unpopular topic eh? - test Pin
Anonymous12-Dec-04 5:38
Anonymous12-Dec-04 5:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.