How to call JavaScript from C# - Cordova/PhoneGap

前端 未结 4 896
生来不讨喜
生来不讨喜 2021-01-18 05:10

I\'m using cordova/phonegap to make a windows phone app, i\'m trying to call a script from C# when an event fires.

Is there anyway to do this?

here\'s my cla

4条回答
  •  太阳男子
    2021-01-18 05:36

    Try:

    webBrowser.InvokeScript("myFunction", "one", "two", "three");
    

    InvokeScript executes a scripting function defined in the currently loaded document, and passes the function an array of string parameters.
    http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff402838%28v=vs.105%29.aspx

    Obviously you have to have the JavaScript function defined in the loaded document.

    Depending on your view it may work like this:

    this.CordovaView.Browser.InvokeScript("eval", new string[] { "yourJavascriptFunction(); " });
    

提交回复
热议问题