Class CoreWebView2NewWindowRequestedEventArgs
Event args for the NewWindowRequested event.
public class CoreWebView2NewWindowRequestedEventArgs : EventArgs
- Inheritance
-
CoreWebView2NewWindowRequestedEventArgs
- Inherited Members
Properties
Handled
Indicates whether the NewWindowRequested event is handled by host.
public bool Handled { get; set; }
Property Value
Remarks
If this is false
and no NewWindow is set, the WebView opens a popup window and returns the opened WindowProxy
to the opener script. Note that in this case, there is no avenue to control the popup window from the app. If set to true
and no NewWindow is set for window.open()
, the opened proxy
is for a dummy window object, but this window does not load and is immediately closed. The default value is false
.
IsUserInitiated
true
when the new window request was initiated through a user gesture such as selecting an anchor tag with target.
public bool IsUserInitiated { get; }
Property Value
Remarks
The Microsoft Edge popup blocker is disabled for WebView so the app is able to use this flag to block non-user initiated popups.
Name
Gets the name of the new window.
public string Name { get; }
Property Value
Remarks
This window can be created via window.open(url, windowName)
, where the windowName parameter corresponds to Name
property.
If no windowName is passed to window.open
, then the Name
property will be set to an empty string. Additionally, if window is opened through other means, such as <a target="windowName">
or <iframe name="windowName">
, then the Name
property will be set accordingly. In the case of target=_blank, the Name
property will be an empty string.
Opening a window via Ctrl+clicking a link would result in the Name
property being set to an empty string.
NewWindow
Gets the new window or sets a WebView as a result of the new window requested.
public CoreWebView2 NewWindow { get; set; }
Property Value
Remarks
Provides a WebView as the target for a window.open()
from inside the requesting WebView. If this is set, the top-level window of this WebView is returned as the opened WindowProxy to the opener script. If this is not set, then Handled is checked to determine behavior for the NewWindowRequested.
The methods which should affect the new web contents like AddScriptToExecuteOnDocumentCreatedAsync(string) has to be called and completed before setting NewWindow. Other methods which should affect the new web contents like WebResourceRequested have to be called after setting NewWindow. It is best not to use RemoveScriptToExecuteOnDocumentCreated(string) before setting NewWindow, otherwise it may not work for later added scripts.
WebView provided in the NewWindow
property must be on the same CoreWebView2Environment as the opener WebView and cannot be navigated. Changes to settings should be made before setting NewWindow to ensure that those settings take effect for the newly setup WebView. The new WebView must have the same profile as the opener WebView.
OriginalSourceFrameInfo
The frame info of the frame where the new window request originated.
public CoreWebView2FrameInfo OriginalSourceFrameInfo { get; }
Property Value
Remarks
The OriginalSourceFrameInfo
is a snapshot of frame information at the time when the new window was requested. See CoreWebView2FrameInfo for details on frame properties.
Uri
Gets the target uri of the new window request.
public string Uri { get; }
Property Value
WindowFeatures
Gets the window features specified by the window.open()
call. These features should be considered for positioning and sizing of new WebView windows.
public CoreWebView2WindowFeatures WindowFeatures { get; }
Property Value
Methods
GetDeferral()
Gets a CoreWebView2Deferral object and put the event into a deferred state.
public CoreWebView2Deferral GetDeferral()
Returns
Remarks
Use this to Complete() the window open request at a later time. While this event is deferred the opener window returns a WindowProxy to an un-navigated window, which navigates when the deferral is complete.