By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,945 Members | 1,432 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,945 IT Pros & Developers. It's quick & easy.

Popup detection

P: n/a
Hi there all,

Is there a way, using Javascript, that you can detect if a popup window has
opened successfully?
I'm tring to work out if someone is running popup blocking software or not.

Cheers,

@ndyB
Jul 23 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
On Thu, 6 May 2004 10:10:11 +0100, Agony.COM <in**@agony.com> wrote:
Is there a way, using Javascript, that you can detect if a popup window
has opened successfully?


Check the Google groups archive for partial solutions. This topic has been
discussed more than once, but I believe the basic answer is, no. At least
not with consistent results.

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 23 '05 #2

P: n/a
In article <40**********************@mercury.nildram.net>,
in**@agony.com enlightened us with...
Hi there all,

Is there a way, using Javascript, that you can detect if a popup window has
opened successfully?


Kinda sorta, but not really.
IOW, not reliably in all browsers.
--
--
~kaeli~
Press any key to continue or any other key to quit
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #3

P: n/a
Original page has the following function:

<script language="JavaScript">
var child=window.open("blah.html","nam","args")

function imHere(){
//if this function is called then the popup is opened
alert("YAY! no popup blocker for me, I'm free to annoy the world!")
}
</script>

child page (blah.html or whatever uses this for verification
<body onLoad="window.opener.imHere()">

"kaeli" <ti******@NOSPAM.comcast.net> wrote in message
news:MP************************@nntp.lucent.com...
In article <40**********************@mercury.nildram.net>,
in**@agony.com enlightened us with...
Hi there all,

Is there a way, using Javascript, that you can detect if a popup window has opened successfully?


Kinda sorta, but not really.
IOW, not reliably in all browsers.
--
--
~kaeli~
Press any key to continue or any other key to quit
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #4

P: n/a
Chris wrote:
Original page has the following function:

<script language="JavaScript">
var child=window.open("blah.html","nam","args")

function imHere(){
//if this function is called then the popup is opened
alert("YAY! no popup blocker for me, I'm free to annoy the world!")
}
</script>

child page (blah.html or whatever uses this for verification
<body onLoad="window.opener.imHere()">

<snip>

Having the page that is loaded in a new window report its presence will
tell you that the page has loaded, from which you may infer that it was
not pop-up blocked. That does not necessarily mean that the next attempt
to open a new window will not be blocked (though it suggests that it is
less likely).

On the other hand, the failure of the new page to report its arrival (or
the fact that it hasn't yet reported its arrival) cannot be used to
deduce that there is a pop-up blocker operating as they are not the only
factor in the failure of a page to load (or a long delay in loading).

It is the pop-up blocker detection that cannot be done, it is only
possible to make inferences about it, and only in such a way as would
make it difficult to meaningfully respond to the inference that a window
opening attempt had been blcoked.

Richard.
Jul 23 '05 #5

P: n/a
Actually Richard, not to seem like an arse or anything, but the function i
posted wasn't intended to be the complete thing, it was there to be adapted.
adding a couple of lines is all that is needed to detect the presence of a
popup blocker, but still; here is the "virtually" complete version
a global variable
var popBlocker=""

and adapting the function imHere...

function imHere(){
//if this function is called then the popup is opened
popBlocker="no"
}

function windowOpen{
if(popBlocker=="" || popBlocker=="no"){
popBlocker="testing..."
var child=window.open("blah.html","nam","args")
}else{
//popupBlocker was found
}
}

"Richard Cornford" <Ri*****@litotes.demon.co.uk> wrote in message
news:c7*******************@news.demon.co.uk...
Chris wrote:
Original page has the following function:

<script language="JavaScript">
var child=window.open("blah.html","nam","args")

function imHere(){
//if this function is called then the popup is opened
alert("YAY! no popup blocker for me, I'm free to annoy the world!")
}
</script>

child page (blah.html or whatever uses this for verification
<body onLoad="window.opener.imHere()">

<snip>

Having the page that is loaded in a new window report its presence will
tell you that the page has loaded, from which you may infer that it was
not pop-up blocked. That does not necessarily mean that the next attempt
to open a new window will not be blocked (though it suggests that it is
less likely).

On the other hand, the failure of the new page to report its arrival (or
the fact that it hasn't yet reported its arrival) cannot be used to
deduce that there is a pop-up blocker operating as they are not the only
factor in the failure of a page to load (or a long delay in loading).

It is the pop-up blocker detection that cannot be done, it is only
possible to make inferences about it, and only in such a way as would
make it difficult to meaningfully respond to the inference that a window
opening attempt had been blcoked.

Richard.

Jul 23 '05 #6

P: n/a
Chris wrote:
Actually Richard, not to seem like an arse or anything,
Top-posting evidence of a failure to comprehend logic to a programming
newsgroup is likely to give that impression.

<snip> adding a couple of lines is all that is needed
to detect the presence of a popup blocker,
The successful loading of a page in a new window could be used to infer
the absence of a pop-up blocker, but failure to load (or very
slow/delayed loading) cannot validly be used to infer the presence of
pop-up blockers. There are just too many other factors influencing that
situation.
but still; here is the
"virtually" complete version a global variable
var popBlocker=""

and adapting the function imHere...

function imHere(){
//if this function is called then the popup is opened
popBlocker="no"
}

function windowOpen{
if(popBlocker=="" || popBlocker=="no"){
popBlocker="testing..."
var child=window.open("blah.html","nam","args")
}else{
//popupBlocker was found

<snip>

But even if you did decide to deduce that a pop-up blocker was operating
when a page has not loaded, the test isn't worth much unless it is in a
position to do something; to react to the (possibly erroneous)
conclusion that a pop-up blocker was operating. As you have written it
you are only in a position to act when you receive confirmation that the
new window was not blocked, which is a situation that probably does not
need any positive/remedial response.

Richard.
Jul 23 '05 #7

P: n/a
Hmm... having just read your email again Richard (after having woken up this
time..) - I apologise for completely missing your point

/me skulks off feeling like a client....

"Chris" <he**********@btinternet.com> wrote in message
news:c7**********@hercules.btinternet.com...
Actually Richard, not to seem like an arse or anything, but the function i
posted wasn't intended to be the complete thing, it was there to be adapted. adding a couple of lines is all that is needed to detect the presence of a
popup blocker, but still; here is the "virtually" complete version
a global variable
var popBlocker=""

and adapting the function imHere...

function imHere(){
//if this function is called then the popup is opened
popBlocker="no"
}

function windowOpen{
if(popBlocker=="" || popBlocker=="no"){
popBlocker="testing..."
var child=window.open("blah.html","nam","args")
}else{
//popupBlocker was found
}
}

"Richard Cornford" <Ri*****@litotes.demon.co.uk> wrote in message
news:c7*******************@news.demon.co.uk...
Chris wrote:
Original page has the following function:

<script language="JavaScript">
var child=window.open("blah.html","nam","args")

function imHere(){
//if this function is called then the popup is opened
alert("YAY! no popup blocker for me, I'm free to annoy the world!")
}
</script>

child page (blah.html or whatever uses this for verification
<body onLoad="window.opener.imHere()">

<snip>

Having the page that is loaded in a new window report its presence will
tell you that the page has loaded, from which you may infer that it was
not pop-up blocked. That does not necessarily mean that the next attempt
to open a new window will not be blocked (though it suggests that it is
less likely).

On the other hand, the failure of the new page to report its arrival (or
the fact that it hasn't yet reported its arrival) cannot be used to
deduce that there is a pop-up blocker operating as they are not the only
factor in the failure of a page to load (or a long delay in loading).

It is the pop-up blocker detection that cannot be done, it is only
possible to make inferences about it, and only in such a way as would
make it difficult to meaningfully respond to the inference that a window
opening attempt had been blcoked.

Richard.


Jul 23 '05 #8

P: n/a
JRS: In article <c7**********@sparta.btinternet.com>, seen in
news:comp.lang.javascript, Chris <he**********@btinternet.com> posted at
Mon, 10 May 2004 01:33:22 :
Lines: 72
Hmm... having just read your email again Richard (after having woken up this
time..) - I apologise for completely missing your point

/me skulks off feeling like a client....

"Chris" <he**********@btinternet.com> wrote in message
news:c7**********@hercules.btinternet.com...
Actually Richard, not to seem like an arse or anything, but the function i
posted wasn't intended to be the complete thing, it was there to be

adapted.

Do not top-post. Do not over-quote. Attribution lines should precede
other material, in almost all circumstances.

Read the newsgroup FAQ until you understand it.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #9

P: n/a
Dr John Stockton wrote:
Do not top-post. Do not over-quote. Attribution lines should precede
other material, in almost all circumstances.
Read the newsgroup FAQ until you understand it.


Do not post to comp.lang.JAVASCRIPT if your post contains no information
relating to JAVASCRIPT.

Suggesting better posting styles is one thing, and leads to a better group
of users. But lately, this group has been overrun by posting-style nazis who
focus more on posting correctly than actually discussing the topic of the
group.

Suggestions for better posting style should only be made in posts that
contain content that is relavent to the topic of the group.

--
Matt Kruse
Javascript Toolbox: http://www.mattkruse.com/javascript/
Jul 23 '05 #10

P: n/a
not quite richard no, if the popup was not blocked, then the variable is set
to "Testing.."
and in that case the thing to do would be to test for that situation and
adapt the website to use the main window instead of the popup

as far as "if the popup didn't load for another reason than a popup blocker,
that's a little anal retentive, since either way the popup didn't load, you
then know about it and can counteract the problems, i don't think the
original plan was to detect a popup blocker, but to detect if the popup
failed to load, and adapt the way the website runs to avoid the EU missing
content

"Richard Cornford" <Ri*****@litotes.demon.co.uk> wrote in message
news:c7*******************@news.demon.co.uk...

[:snip:]
function windowOpen{
if(popBlocker=="" || popBlocker=="no"){
popBlocker="testing..."
var child=window.open("blah.html","nam","args")
}else{
//popupBlocker was found

<snip>

But even if you did decide to deduce that a pop-up blocker was operating
when a page has not loaded, the test isn't worth much unless it is in a
position to do something; to react to the (possibly erroneous)
conclusion that a pop-up blocker was operating. As you have written it
you are only in a position to act when you receive confirmation that the
new window was not blocked, which is a situation that probably does not
need any positive/remedial response.

Richard.

Jul 23 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.