I'm using a WebView2 on Windows Forms. I want to get that image src from html and show it in a MessageBox
<div style="z-index:900;padding:0">
<img id="imageCodeDisplayId" width="180" height="50" ng-src="mysite.com/wp-content/uploads/img.jpg" alt="Verify Image" style="padding:2px;border-style:solid;border-width:1px;border-color:#CCC;margin-top:5px;margin-bottom:5px" src="mysite.com/wp-content/uploads/img.jpg">
<a aria-hidden="true" title="Reload" style="cursor:pointer;font-size:30px;top:10px;left:10px;text-decoration:none" ng-click="getCaptcha()"></a>
</div>
CodePudding user response:
You can use document.getElementById('imageCodeDisplayId').src
to access the src attribute of the img element.
All extra necessary information is available at Get started with WebView2 in WinForms apps
And also WebView2.ExecuteScriptAsync(String) Method describes everything that you need to use it.