Computing.Net > Forums > Web Development > Determine if Pop-up was blocked

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to get for your free account now!

Determine if Pop-up was blocked

Reply to Message Icon

Name: RTAdams89
Date: December 31, 2008 at 15:20:04 Pacific
OS: XP Pro SP3
CPU/Ram: na
Manufacturer/Model: N/a / NA
Subcategory: Javascript/Ajax
Comment:

I have a page (eventsubmit.php) which adds calendar events to my database, tells the user the event was added, then closes. Additionally, this page opens another page (email.php) which is used to further process data.

Currently, the eventsubmit.php page uses JavaScript "window.setTimeout('window.close()', 1000);" in the head to close the page, and a function which is called onload to open the email.php page.

The email.php page is prevented from opening on some of my user's computers by their pop-up blockers. Is there a way to determine if the email.php page was opened successfully, and if not, stop the eventsubmit.php page from closing and display a manual link to open the email.php page?

-Ryan Adams
Free Computer Tips and more:http://RyanTAdams.com

Paid Tech Support: Black Diamond


Report Offensive Message For Removal

Sponsored Link
Ads by Google

Response Number 1
Name: shutat
Date: December 31, 2008 at 20:39:23 Pacific
Reply:

I'm not sure on the JS question, but I *may* have a straight php solution if I understood your problem right.

However, one pitfall is the embedded php code will only execute once, so you may have to reload the page depending on what you're up to in event submit script.

The upside, if it helps you out, is it doesn't rely on JS at all.

<?php

global $meta;
global $outp;

$meta = null;
$outp = null;

if(isset($_POST["evtsub"]) && $_POST["evtsub"] === "Calendar") {
$outp = "the event was added";
$meta = "<meta http-equiv='refresh' content='1; url=email.php'>";
}
?>
<html>
<head>
<?php if($meta != null && $outp != null) { echo $meta . "\n"; }?>
</head>
<body>
<?php if($outp != null) { echo $outp; } else {?>
<form action='<?php echo $_SERVER["PHP_SELF"];?>' method='post'>
<input name='evtsub' value='Calendar' type='submit'>
</form>
<?php }?>
</body>
</html>


Report Offensive Follow Up For Removal

Response Number 2
Name: Michael J (by mjdamato)
Date: January 1, 2009 at 02:38:47 Pacific
Reply:

The simplest solution is to try and set a cookie on a pop-up page. If the cookie is set then you know the popup was not blocked.

Michael J


Report Offensive Follow Up For Removal

Response Number 3
Name: RTAdams89
Date: January 1, 2009 at 11:06:03 Pacific
Reply:

What if I opened the popup, then used the "window.closed" property to check if the window as open. If "window.closed" is false, then the original page closes. If it is true, the original page stays open and displays a link to manually open the popup. Would that work?

-Ryan Adams
Free Computer Tips and more:http://RyanTAdams.com

Paid Tech Support: Black Diamond


Report Offensive Follow Up For Removal

Response Number 4
Name: Michael J (by mjdamato)
Date: January 1, 2009 at 21:30:19 Pacific
Reply:

Try it.

The problem with that approach (IMHO) is that it relies entirely on javascript. So, if the user has javascript disabled it won't work. By setting a cookie with javascript AND checking that cookie through the back end (PHP) you can kill two birds with one stone.

Michael J


Report Offensive Follow Up For Removal
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: Determine if Pop-up was blocked

Bypass Pop-up blocker www.computing.net/answers/webdevel/bypass-popup-blocker/2429.html

IIS System Tray Pop-up www.computing.net/answers/webdevel/iis-system-tray-popup/3440.html

java script pop up www.computing.net/answers/webdevel/java-script-pop-up/1975.html