Hi I am trying to dynamically open a popup window but ie8 blocks it with the popup blocker.

basically within a ajax fuction I have a confirm button and if the user clicks yes it opens a popup window.

now I tried it with a javascript function but it got blocked, so I have tried it by creating a form with a button in it and instead of calling the popup function direct I call document.form.button.click

and in the form my button has onclick"popup('<? echo url; ?>')"

but this also is detected as a unwarranted popup and is blocked.

now I understand that the popup blocker works when a popup is called without user interaction, but allows popups on say button clicks.

how can I get the popup to work

any help and I would be hugely grateful

many thanks
Barry

dont use a popup,
you are already using ajax functions, so use ajax to put the form in a layer, and onclick change the z-index and visibility of the layer to put it on top of everything else, so the user has to complete the form and submit/close the layer to continue
the same functionality as the private message prompts on this forum
this is a scrap of

<button id="frorm" align="center" onClick="showIt();">Important Information</button><script type="text/javascript">
<!--
(document.getElementById) ? dom = true : dom = false;
function hideIt() {
if (dom) {document.getElementById("layerm1").style.visibility='hidden';}
if (document.layers) {document.layers["layerm1"].visibility='hide';} }
function showIt() {
if (dom) {document.getElementById("layerm1").style.visibility='visible';}
if (document.layers) {document.layers["layerm1"].visibility='show';} }
--></script><div id="layerm1" style="position:fixed; left:10px; top:30px; width:95%; visibility:hidden; padding:10px; margin:10px; background:#ececec; border: 1px solid black;">
AJAX FORM
<button id="form" onClick="hideIt();">Close</button></div>

that demonstrates the principle, but not the ajax needed to replace that TEXT with your form

My problem is that the layer must hold a private chat window run in ajax and within that window are php/mysql functions, so unless a layer can include code then I cannot use it

the layer can include any code you want, its just a html element, div p span table, the chat window, anything can be a layer

as I understand it thats what ajax does
ajax is returning php to a part of the current window
I'm not confident with ajax code
but at worst you could the chat in an iframe in the layer (tacky)
and put the close button in the chat page as onclick='top.hideIt();' its certain that a popup window is not going to work, malware concerns mean nobody will disable their popup blocker

you could probably copy the ajax chat code into the <div></div>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.