...

View Full Version : stupid pop up blocker



timgolding
03-22-2012, 02:06 PM
pop up blocker is stopping my user action from using window.open. It is a html button that i want to open a dialog to tell the user his item was added to the shopping cart. The sumbit_cart() function is supposed to send a request via ajax then use window.open to open the dialog if the ajax function was successful.



<input type="button" value="Add to Cart" onclick="return submit_cart();" />


I can understand the pop up blocker from blocking random pop ups but this is a user triggered event i don't see why it isn't allowing it.

What can i do to make this work?

Philip M
03-22-2012, 05:47 PM
Simple - don't use a popup. A modal dialog will in any case quickly bore and irritate your users. Show your message, for example, in a <span> with display:inline.


All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

timgolding
03-22-2012, 06:07 PM
Maybe i will do that if i cant find a solution to using the pop up. I didn't want it to direct to another page but i guess i could try some sort of hidden element if not.

Old Pedant
03-23-2012, 12:36 AM
Use a POPON instead of a popup.

Like this, for example:



<html>
<body>
<div id="POPON"
style="position: absolute; top: 200px; left: 100px; height: 200px; width: 300px;
background-color: lightblue; border: solid blue 3px;display: none;">
<div style+width: 100%; text-align: right;">
<a href="#" onclick="document.getElementById('POPON').style.display='none';return false;">
click here to close
</a>
</div>
<div id="POPMESSAGE" style="margin-top: 40px;text-align: center;color: blue;"></div>
</div>
...
<script type="text/javascript">
function showPopon( msg )
{
document.getElement("POPMESSAGE").innerHTML = msg;
document.getElement("POPON").style.display = "block";
}
</script>
...

timgolding
03-23-2012, 11:08 AM
Thanks for the code ill give it a try


Got it working it looks good thanks. Just got to see what my boss thinks of it now....

Mishu
03-25-2012, 04:39 AM
I can understand the pop up blocker from blocking random pop ups but this is a user triggered event i don't see why it isn't allowing it.


Users should, and do, have the final say in whether popups are allowed or not. Not the web developer. Just because a user clicks a button, doesn't mean they would have clicked the button if they knew doing so would open a popup. For critical things you can create and style your own html element on the page to make it look like a popup.

rnd me
03-25-2012, 09:11 AM
I can understand the pop up blocker from blocking random pop ups but this is a user triggered event i don't see why it isn't allowing it.

What can i do to make this work?


look like folks are avoiding the question...

it's not a user-triggered event. the ajax fetch is a user-triggered event.

later on, the returning ajax callback invokes window.open().

since this is after a user click, and the ajax event is async, the open() command is not on the same stack as a legit user click.

you can open a window immediately in the click , then fill in the popup when the ajax completes (ala popupObject.document.body.innerHTML="done")
this also gives you a space and method to report progress on long-running queries.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum