I have the code to detect and alert the user of my pop up being blocked. Is it also possible to have the user click ok to open the pop up? If so, can someone post that code for me, please? Thanks.

8 Years
Discussion Span
Last Post by Reliable

Im not sure if this is what you need. But may be this wil claim your issue, simply insert the code below, between the head section of your page:

<script type="text/javascript">
window.onload = function(e) {
try { var askThem = ( confirm('Do you wish to load any popup\'s  from this site?', 'Demo') == true ) ? window.open('yourPopUp.html',target='_blank','width=500,height=500,location=no,status=no,menubar=no,toolbar=no,scrollbars=no') : alert('Welcome to my Website!'); }
catch(e) { }

Dont use popup that can be blocked
use a layer and have the javascript event change the layer's viisiblity
something like

.top { background-color: #000070; color: #ffffff; text-align: right; }
.bottom {  background-color: #efefef; padding: 15px; }
<script language="javascript" type="text/javascript">
(document.getElementById) ? dom = true : dom = false;
function hideIt() {
 if (dom) {document.getElementById("layer1").style.visibility='hidden';}
 if (document.layers) {document.layers["layer1"].visibility='hide';} }
function showIt() {
 if (dom) {document.getElementById("layer1").style.visibility='visible';}
 if (document.layers) {document.layers["layer1"].visibility='show';} }
onResize="window.location.href = window.location.href"
<button id="form" onClick="showIt();">Important Information</button>
<div id="layer1" style="position:fixed; left:20px; width:45%; top:20px; visibility:hidden;">
<div onClick="hideIt()" class="top">
<font Color="#ffffff"><Strong>Close</strong></font>
<div class="bottom">
blah blah bla<br>
Important info<br>
bla blah bla

there are two for each fuction, one IE one Mozilla


I tried the code given for the OK button on the alert message to open a window, but browsers still detect a pop up and block the window. I would like to circumvent pop up detection so the pop up immediately opens up once the OK button is pressed on the alert message.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.