Opens a pop-up window.
Assembly: System.Windows.Browser (in System.Windows.Browser.dll)
[SecuritySafeCriticalAttribute] public static HtmlWindow PopupWindow( Uri navigateToUri, string target, HtmlPopupWindowOptions options )
- Type: System.Uri
Specifies the Uniform Resource Identifier (URI) for the pop-up window.
- Type: System.String
Specifies the window that will be opened. (For more information, see the Remarks section.)
Return ValueType: System.Windows.Browser.HtmlWindow
A handle to the new window; or null (see the Remarks section).
This method is intended as a simple way for site authors to host cross-domain advertising content that needs to pop up a window when the user clicks the content. Therefore, this method provides a constrained way to trigger pop-up windows while bypassing the browser's pop-up blockers. This method is also available for developers who are running Silverlight-based applications from the same domain and who want to reliably create pop-up windows without triggering pop-up blockers.
This method temporarily turns off the browser's pop-up blockers. Therefore, additional constraints exist for this method to run:
The AllowHtmlPopupWindow property must be set to true on the Silverlight plug-in.
The call to must be triggered by a user-initiated click on a visible area of the hosting Silverlight plug-in.
can be called only once per interactive user event. This prevents the display of multiple pop-ups during the course of a single click on the Silverlight plug-inl.
Call the IsPopupWindowAllowed property to determine whether the above constraints are met.
Behaviors and Return Values
This method returns an HtmlWindow handle to the new window if the following requirements are met:
The EnableHtmlAccess property is set to true.
IsPopupWindowAllowed returns true.
The method returns null if any of the previous requirements are not met.
The Pop-up Window Target
The target of the window navigation differs depending on whether the Silverlight-based application has been granted HTML access (either through the EnableHtmlAccess property or the IsEnabled property). Empty strings and null are allowable values for the target parameter.
If EnableHtmlAccess is set to true, both null and non- null values of target are passed to the browser.
If EnableHtmlAccess is set to false, "_blank" is used as the target of the new window.
Customizing the Target Window
If you specify options, the following additional constraints on the window size are imposed:
To prevent displaying a pop-up window that overlays the entirety of a user's desktop window, this method internally decreases the pop-up's height to 250 pixels less than the available screen height, and the pop-up's width to 200 pixels less than the available screen width of the user's desktop. In Internet Explorer, the available screen height and width can be found by using the Document Object Model (DOM) navigator.screen.availHeight and navigator.screen.availWidth properties.
To prevent displaying a pop-up window that appears off-screen, the method internally reduces the pop-up's top coordinate to 100 pixels less than the maximum top coordinate of the screen, and the pop-up's left coordinate to 100 pixels less than the maximum left coordinate of the screen. Therefore, if the top and left values are both set to off-screen coordinates, this method internally changes the coordinates of the new window so that it is displayed in the lower-right corner of the screen with width and height set to 100 pixels each.
Also, the browser has minimum height and width values that prevent the display of arbitrarily small windows.
In Internet Explorer, the browser's pop-up blocker must be configured to Medium or lower.
In Firefox (Windows and Macintosh), pop-up windows are available with the default Firefox security settings.
In Safari, pop-up windows are not available.
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.