Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Calling Ti API from WebView JavaScript Only Works When HTML is Local?

Hello,

In the local_webview.js file in KitchenSink, there's an example where clicking a div on the web page calls some native Titanium methods, such as Ti.API.info (see lines 46-50).

I tried doing something similar, but in my example, the web page that's displayed in the WebView is coming from a remote server, not a local HTML like the KitchenSink example. In this case, I can't get the calls to native Ti functions like Ti.API.info to work. I tried it on both Android and iPhone.

Is this expected? Do calls to native Ti functions from a web page's JavaScript only work when the HTML is coming from a local file?

Thanks!!!

-Ryan

— asked September 21st 2010 by Ryan Asleson
  • android
  • iphone
  • webview
0 Comments

1 Answer

  • Yes, only from a local source.

    — answered September 21st 2010 by Don Thorp
    permalink
    3 Comments
    • what do you mean for "local"? I have a local html file that is loaded in a webview. The browser, once the project is compiled, can't execute Ti.* operations such as Ti.App.fireEvents or Ti.API.info.

      the project works fine in native apps.

      — commented March 13th 2013 by dario rusignuolo
    • Code example?

      — commented March 14th 2013 by Mark M
    • pls add code…..

      — commented March 21st 2013 by almamun binmozid
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.