I can inject JavaScript in WebBrowser control in C# windows form by this link
How to inject JavaScript in WebBrowser control?
But I can\'t do this in WP7, pl
For desktop WebBrowser (WinForms/WPF), at least one tag has to be present on the web page for InvokeScript("eval", ...) to work. I.e., if the page doesn't contain any JavaScript (e.g. ), eval doesn't work as is.
I don't have Windows Phone SDK/emulator installed to verify if this is also the case with Windows Phone WebBrowser.
Nevertheless, the following works for a Windows Store App. The trick is to use this.webBrowser.InvokeScript("setTimeout", ...) to inject some JavaScript first. I'm using it instead of execScript, which is deprecated since IE11.
async void MainPage_Loaded(object sender, RoutedEventArgs e)
{
// load a blank page
var tcsLoad = new TaskCompletionSource
I would appreciate if someone can confirm whether this works or not for WP WebBrowser. LoadCompleted should be used for WP instead of NavigationCompleted in the code above, and WebBrowser.IsScriptEnabled has to be set to true.