Share via


WebChromeClient.OnCreateWindow(WebView, Boolean, Boolean, Message) Method

Definition

Request the host application to create a new window.

[Android.Runtime.Register("onCreateWindow", "(Landroid/webkit/WebView;ZZLandroid/os/Message;)Z", "GetOnCreateWindow_Landroid_webkit_WebView_ZZLandroid_os_Message_Handler")]
public virtual bool OnCreateWindow (Android.Webkit.WebView? view, bool isDialog, bool isUserGesture, Android.OS.Message? resultMsg);
[<Android.Runtime.Register("onCreateWindow", "(Landroid/webkit/WebView;ZZLandroid/os/Message;)Z", "GetOnCreateWindow_Landroid_webkit_WebView_ZZLandroid_os_Message_Handler")>]
abstract member OnCreateWindow : Android.Webkit.WebView * bool * bool * Android.OS.Message -> bool
override this.OnCreateWindow : Android.Webkit.WebView * bool * bool * Android.OS.Message -> bool

Parameters

view
WebView

The WebView from which the request for a new window originated.

isDialog
Boolean

true if the new window should be a dialog, rather than a full-size window.

isUserGesture
Boolean

true if the request was initiated by a user gesture, such as the user clicking a link.

resultMsg
Message

The message to send when once a new WebView has been created. resultMsg.obj is a WebView.WebViewTransport object. This should be used to transport the new WebView, by calling WebView.WebViewTransport#setWebView(WebView) WebView.WebViewTransport.setWebView(WebView).

Returns

This method should return true if the host application will create a new window, in which case resultMsg should be sent to its target. Otherwise, this method should return false. Returning false from this method but also sending resultMsg will result in undefined behavior.

Attributes

Remarks

Request the host application to create a new window. If the host application chooses to honor this request, it should return true from this method, create a new WebView to host the window, insert it into the View system and send the supplied resultMsg message to its target with the new WebView as an argument. If the host application chooses not to honor the request, it should return false from this method. The default implementation of this method does nothing and hence returns false.

Applications should typically not allow windows to be created when the isUserGesture flag is false, as this may be an unwanted popup.

Applications should be careful how they display the new window: don't simply overlay it over the existing WebView as this may mislead the user about which site they are viewing. If your application displays the URL of the main page, make sure to also display the URL of the new window in a similar fashion. If your application does not display URLs, consider disallowing the creation of new windows entirely. <p class="note"><b>Note:</b> There is no trustworthy way to tell which page requested the new window: the request might originate from a third-party iframe inside the WebView.

Java documentation for android.webkit.WebChromeClient.onCreateWindow(android.webkit.WebView, boolean, boolean, android.os.Message).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to