Type: Boolean
Returns True if the user has their browser or other software on their machine set to block pop up windows, false otherwise.
Although pop up windows have a poor reputation (mainly due to annoying popup ads), there are several legitimate uses for popups, including controlling the window's characteristics (such as size and location), navigation, and providing warnings for sessions about to time out. The PopupsBlocked property is therefore very useful for knowing in advance whether the window you expect to pop up will open successfully.
This test involves opening a small popup window which then immediately closes itself. There is also an Advanced Option available if you want to use your own popup window for this test instead of the default BrowserHawk popup test window. This gives you greater control over the look, placement, and size of the test popup window.
A popular use of the Advanced Option is to have BrowserHawk pop up your real pop up window and leave it open, and have BrowserHawk return a value that indicates whether your window was successfully opened - without the need to use BrowserHawk's default test popup window. This Advanced Option is covered in great detail in the popupcheck.asp sample.
The popup test uses a timeout value as determined by the PopupTimeout property, which defaults to 2000 milliseconds (2 seconds). If BrowserHawk determines that the popup window is not opened within this many milliseconds, popups are considered blocked. This means that for users with blocked popups, the popup detection test will take X milliseconds to complete, where X is the value of the PopupTimeout property. If popups are not blocked the test completes instantly. See details on the PopupTimeout property for more information before changing this value.
Tip: See the source for the BrowserHawk popupcheck.aspx sample (\Program Files\cyScape\BrowserHawk\samples\dotnet) for more details on detecting blocked popups, including details on how to use the Advanced Option discussed above.
Note: Use of this property requires the Enterprise Edition of BrowserHawk.
C# Example (basic option):
<%
ExtendedOptions options = new ExtendedOptions();
options.AddProperties("PopupsBlocked");
options.PageMessage = "Please wait, testing your browser…";
options.PageTitle = "Please wait";
ExtendedBrowserObj extBrow = BrowserObj.GetExtendedBrowser(options);
%>
<html> Popups blocked? <% = extBrow.PopupsBlocked.ToString() %> </html>
C# Example (advanced option):
<%
ExtendedOptions options = new ExtendedOptions();
options.AddProperties("PopupsBlocked");
options.PageMessage = "Please wait, testing your browser…";
options.PageTitle = "Please wait";
options.PopupFileName = "myPopup.aspx";
options.PopupWindowName = "MyPopup";
options.PopupWindowFeatures = "width=300,height=150,location=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,top=300,left=300";
ExtendedBrowserObj extBrow = BrowserObj.GetExtendedBrowser(options);
%>
<html>
<% if (extBrow.PopupsBlocked) %>
Sorry, popups are blocked and the popup from myPopup.asp was not shown
<% else %>
Popups are not blocked and the popup from myPopup.asp is now on the screen!
</html>
For the above example to work you must create a file called myPopup.aspx with the following contents and place it in the same directory as the example:
<html>
<head>
<script>function bhcheck() {}</script>
</head>
<body>
Hello from myPopup!
</body></html>
Important Note: When using the Advanced Option you must add the following line of JavaScript, as is, to the <HEAD></HEAD> section of your popup window:
<script>function bhcheck() {}</script>
Special notes for this property:
If the user’s JavaScript is disabled this property will not be available.
As part of this test, BrowserHawk attempts to popup a small popup window which closes itself immediately. If popups are not blocked, this window will be seen for a split second. If popups are blocked, any notification such as a sound or visual that the user has set will indicate that a popup window was blocked. This is as designed.
If you have a popup you want displayed to the visitor, BrowserHawk can use your own popup window as part of this test and keep it open, rather than using its own test window and opening and closing it, just to have you then pop your own window up. See the Tip for the Advanced Option mentioned above.
For users with blocked popups, this test will take X milliseconds to complete, where X is determined by the PopupTimeout property. This is 2000 milliseconds (2 seconds) by default. There are tradeoffs in changing this value from its default. See the PopupTimeout property for more information.
You cannot perform a test for ConnectionSpeed and PopupsBlocked from the same script. Doing so will cause invalid speed measurements. If you need to test both connection speed and blocked popups, do so from separate scripts.
The test for PopupsBlocked is not included when asking for "all" tests to be performed. Therefore even if you are calling AddProperties and specifying "all", you must also explicitly request the PopupsBlocked test using AddProperties.
See Also: