PopupsBlocked Property

 

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.asp sample (\Program Files\cyScape\BrowserHawk\samples\ASP) for more details on detecting blocked popups, including details on how to use the Advanced Option discussed above.

 

Note: You must call the GetExtPropertiesEx method before checking the value of this property. This property requires the Enterprise Edition of BrowserHawk.

 

Example (basic option):

<% set bhObj = Server.CreateObject("cyScape.browserObj")

bhObj.SetExtProperties "PopupsBlocked"

bhObj.GetExtPropertiesEx 0, "", "Please wait", "Checking your browser, please wait…"

%>

<html> Popups blocked? <% = bhObj.PopupsBlocked %> </html>

 

Example (advanced option):

<% set bhObj = Server.CreateObject("cyScape.browserObj")

bhObj.SetExtProperties "PopupsBlocked"

bhObj.PopupFileName = "myPopup.asp"

bhObj.PopupWindowName = "myPopup"

bhObj.PopupWindowFeatures = "width=300,height=150,location=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,top=300,left=300"

bhObj.GetExtPropertiesEx 0, "", "Please wait", "Checking your browser, please wait…"

%>

<html>

<% if bhObj.PopupsBlocked then %>

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!

<% end if %>

</html>

 

For the above example to work you must create a file called myPopup.asp 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:

 

See Also:

PopupFileName Property

PopupTimeout Property

PopupWindowFeatures Property

PopupWindowName Property

GetExtPropertiesEx Method