You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to be able to inject different scripts into individual frames. An AddScriptToExecuteOnDocumentCreatedAsync method for CoreWebView2Frame might be sufficient. I'm using WebView2 in a .NET WPF app via the Microsoft.Web.WebView2 package.
The scenario/use case where you would use this feature
I'm injecting scripts that contain a subscriber ID and access token for the page, as well as JS code that uses this information for connecting to a backend service. However, I want the scripts to be different for each iframe because I want to treat them as unique subscribers. Some scripts I want to inject to the top level frame only, to avoid information leakage in case that top level frame loads some external page. The behavior and API for injecting scripts should be the same for windows created with window.open() and iframes.
How important is this request to you?
Impactful. My app's user experience would be significantly compromised without it.
Suggested implementation
No response
What does your app do? Is there a pending deadline for this request?
I'm currently experimenting with various WV2 methods and events, my working theory is this:
Remove all injected scripts in FrameCreated event handler
Cancel navigation in FrameNavigationStarting event handler, and start a sequence when I inject scripts and then navigate the frame - unfortunately there's no reference to the frame in the event args, so this is probably a dead end.
The text was updated successfully, but these errors were encountered:
I did a super hacky workaround where the injected script fetches the actual scripts from a host object and runs them with eval... But I'm not sure about eval's limitations.
Describe the feature/enhancement you need
I'd like to be able to inject different scripts into individual frames. An
AddScriptToExecuteOnDocumentCreatedAsync
method forCoreWebView2Frame
might be sufficient. I'm using WebView2 in a .NET WPF app via theMicrosoft.Web.WebView2
package.The scenario/use case where you would use this feature
I'm injecting scripts that contain a subscriber ID and access token for the page, as well as JS code that uses this information for connecting to a backend service. However, I want the scripts to be different for each iframe because I want to treat them as unique subscribers. Some scripts I want to inject to the top level frame only, to avoid information leakage in case that top level frame loads some external page. The behavior and API for injecting scripts should be the same for windows created with
window.open()
and iframes.How important is this request to you?
Impactful. My app's user experience would be significantly compromised without it.
Suggested implementation
No response
What does your app do? Is there a pending deadline for this request?
I'm currently experimenting with various WV2 methods and events, my working theory is this:
FrameCreated
event handlerFrameNavigationStarting
event handler, and start a sequence when I inject scripts and then navigate the frame - unfortunately there's no reference to the frame in the event args, so this is probably a dead end.The text was updated successfully, but these errors were encountered: