WebView2ControlMBS Source

Is there a way for WebView2ControlMBS to get the source of the page like the HTMLViewer example below?

dim b as ChromiumBrowserMBS = HTMLViewer1.ChromiumBrowserMBS
if b<>Nil then
dim m as ChromiumFrameMBS = b.mainFrame
if m<>Nil then
dim t as string = m.Source
txtSource.Text = t
end if
end if

I think I can just add a few new functions there for you.

1 Like

HTMLText and PlainText methods added. I’ll send you a link for a new plugin. Please try.

1 Like

Thanks Christian, I’ll be looking for it.

Christian, did you say there was a new version? Or is it still being worked on? Just curious, thanks.

I emailed you a link!?

here is it:

Didn’t get the email, maybe it was in my spam folder or something. Either way I got this download. I’ll try it out, Thanks!

It will also be part of next pre-release next week.

Christian,
Do you have an example on how to get the HtmlText from the WebView2ControlMBS control? Like my initial question, I know how to get it from the ChromiumBrowserMBS but can’t seem to figure out the syntax for the WebView2ControlMBS. I’d like to populate a Text Area (txtSource.Text) with the source of the browser.Thanks.

Just like this:

dim web as WebView2ControlMBS // your control

dim text as string = web.plaintext
dim html as string = web.HTMLText

break // check in debugger

Hmm, that is what I had assumed. I have the control in a window, the control is called “web”, I have a button with the code below, I also put the code in the navigation completed and both give me a nilExceptionError.

dim web as WebView2ControlMBS
dim html as string = web.HTMLText
txtSource.Text = html
msgbox(html)

And what is the text message in the exception?

Ah, web must be the control name you use, not a nil variable.

Ugh, thought I tried that too, I guess not. Got it now. Thanks!

And our pr7 is online, so everyone can try it.