R2D221 / WebView2.DOM

C# DOM bindings to be used with WebView2
MIT License
51 stars 10 forks source link

How can we access window.frames? #12

Closed pjacko closed 1 year ago

pjacko commented 2 years ago

Hi there, is it possible to access frames and iframes within the window? If so how? thanks

R2D221 commented 2 years ago

As of now, frames are not supported. Since this project works by injecting code at the beginning of each navigation, it would also have to inject code into the frames. I'm not sure if this could work within my model.

I'm leaving this issue open, in case I find out a way to support frames.

pjacko commented 2 years ago

Thanks for the response. However I still have to deal with frames. Just wondering if I could inject the code manually into a specified frame?

R2D221 commented 1 year ago

The latest version 0.6.2 now includes window.frames as a collection you can use like so:

foreach (var frame in window.frames)
{
    // frame.GetType() == typeof(Window)
    var testElement = frame.getElementById("test"); // gets id=test directly from an iframe
}

Please let me know if this is what you were looking for.

pjacko commented 1 year ago

Thanks for that, I'll give it a whirl