Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Legally avoiding popup blocking

Tags:

javascript

What is causing some browsers to see my code as unsolicited?

I have a web site devoted to helping people with interactive sessions. It starts with the user clicking [Begin] so this is a consented action. This should (1) open a popup while (2) redirecting the first page to a end page as below :

<head>  
<SCRIPT language="JavaScript">
      function openwindow(){window.open("{INTERACTION}","interaction","resizable=0,width=800,height=600,status=0");}</SCRIPT>
</head>   
<body>
<FORM action="end.php" method="{METHOD}" >  
<input type="submit"  class="button" 
       onClick="javascript: openwindow()" 
       value="Begin" />
</FORM>
</body>

As said, this is not trying to open an unrequested popup but some strains of IE and Chrome appear to be treating it as such. I have been trying to get a fix, most recently digesting this post.

In it Bobince comments

these days, you don't really need to ask the question “was my unsolicited popup blocked?”, because the answer is invariably “yes” — all the major browsers have the popup blocker turned on by default. Best approach is only ever to window.open() in response to a direct click, which is almost always allowed.I'm quite happy to buy into this principle because I simply want my popup to open.

What is causing some browsers to see my code as unsolicited?

I'd appreciate any help you could give me. (as you might have guessed, client side is not my bag and this topic has been bugging me for ages).

Many thanks in advance (and fingers crossed) Giles

like image 741
giles Avatar asked May 31 '11 20:05

giles


People also ask

How do you bypass a pop-up blocker?

Click the Open menu button (three bars) in the upper-right corner. Click Options or Preferences. Select Privacy & Security on the left. Uncheck Block pop-up windows to disable the pop-up blocker.

Should pop-ups be blocked?

In general, most pop-ups are a nuisance – they are usually advertisements and can even be malware, and most people would prefer not to see them. As a general rule, you should leave your browser's pop-up blocker turned on to avoid getting these pop-ups.

Do not allow any site to show pop-ups recommended?

Google ChromeIn the "Pop-ups" section, select Allow all sites to show pop-ups or Do not allow any site to show pop-ups (recommended). To customize permissions for specific websites, click Manage exceptions.

Why are some pop-ups not blocked?

Adware Circumvents Blockers Similar to malware, adware can get around pop-up blockers and launch pop-up windows. Adware is different from malware in that it legitimately installs itself with the user's permission, even though the user might not actually recognize what they're approving.


2 Answers

No much you can do. You could ask your users to disable pop-up blockers or inform them that a pop-up blocker is enabled by checking the window object ref returned by window.open()

e.g.

var w = window.open('http://domain.com');
if(!w) { 
   //an alert in this example
   alert('oops..seems like a pop-up blocker is enabled. Please disable');
}

you could find another way and try what Brad suggests.

like image 190
Andreas Avatar answered Oct 14 '22 16:10

Andreas


There isn't anything you can do about this. Some popup blockers still block everything, even in response to a user clicking. The best you can do is suggest your users turn off popup blockers, or find a different way to do what you want to do. A popular method is the div that appears on top of all others on your page, like Lightbox.

There are many jQuery plugins which make this easy.

like image 4
Brad Avatar answered Oct 14 '22 15:10

Brad