dimanche 28 décembre 2014

C# WP8.1 WebView set focus on a HTML DOM element to zoom and bring up keyboard


Any way in WP8.1 to set focus on a HTML DOM element from code-behind so that a WebView automatically zooms to focus on the element and bring up the on-screen keyboard?


Currently doing something like this:



private async void WebView_DOMContentLoaded(WebView sender, WebViewDOMContentLoadedEventArgs args) {
try {
await WebView.InvokeScriptAsync("eval", new string[] { "document.getElementsByName('some_input')[0].focus();" }); // fpcus
await WebView.InvokeScriptAsync("eval", new string[] { "document.getElementsByName('some_input')[0].click();" }); // click
} catch (Exception) { }
}


But the WebView does not zoom or bring up the on-screen keyboard. It simply "focuses" on the element (showing a focused input border).


Any help would be greatly appreciated.


Thanks.





Aucun commentaire:

Enregistrer un commentaire