Trying to call C# code with a JavaScript button on a WebView
<p>Note that I'm specifically talking about calling C# after clicking on a Javascript button that is inside my webview, in this case a <code>HybridWebView</code>.</p>

<p>I followed a lot of tips and ideas I seen around like the samples provided by <a href="https://github.com/XLabs/Xamarin-Forms-Labs" rel="nofollow noreferrer">XLabs</a> and the documentation about <code>HybridWebViews</code> in the Xamarin.Forms guides.</p>

<p>I have the following structure:</p>

<p><code>Hybridwebview</code> Class with the methods to <code>RegisterAction</code> and <code>InvokeAction</code>;</p>

<p><code>Page</code> that uses my <code>HybridWebView</code>;</p>

<p>A custom renderer in each of my platforms that are injecting the Javascript I want in the webview.</p>

<p>I believe the problem is in the <code>InjectJS</code> method that I have in my renderer. It is using <code>LoadUrl</code> to inject javascript in the <code>WebView</code> and that is "deleting" my <code>WebView</code> and replacing it with the button that has the Javascript function.</p>

<p>This is the code of my renderer for Android!
<a href="https://i.stack.imgur.com/qe8EC.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qe8EC.jpg" alt="This is the code of my renderer for Android"></a></p>

<p>On the left is the result that this creates and on the right the result I was expecting
<a href="https://i.stack.imgur.com/h7EwQ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/h7EwQ.jpg" alt="On the left is the result that this creates and on the right the result I was expecting"></a></p>