【问题标题】:Titanium webview local html Ti is not definedTitanium webview 本地 html Ti 未定义
【发布时间】:2015-02-20 05:28:48
【问题描述】:

您好,有谁知道如何使用本地 html 文件在钛 webview 中解决此问题??

Ti 未定义

在我的 本地 html 文件中

<input type="radio" name="radio" id="radio1" onclick="Ti.App.fireEvent('app:fromWebView',{ message: 'hi' });"/>

在我的钛应用程序文件我有以下代码

Ti.App.addEventListener('app:fromWebView', function(d) {

if(d.message== 'hi'){

alert('hi');

};

});

有人知道如何解决这个问题吗?..

我正在使用钛 sdk 3.4.0

【问题讨论】:

    标签: android webview titanium titanium-mobile titanium-alloy


    【解决方案1】:

    应该这样工作,可能注释掉所有其他代码并尝试这个基本示例 (https://wiki.appcelerator.org/display/guides2/Communication+Between+WebViews+and+Titanium):

    index.js:

    var win = Ti.UI.createWindow();
      var webview = Ti.UI.createWebView({
      url: 'test.html'
    });
    
    
    Ti.App.addEventListener('app:fromWebView', function(e) {
      alert(e.message);
    });
    
    win.add(webview);
    win.open();
    

    test.html:

    <html>
    <body onload="Ti.API.info('body loaded!');">        
        <button onclick="Ti.App.fireEvent('app:fromWebView', { message: 'event fired from WebView, handled in Titanium' });">fromWebView</button>
    </body>
    </html>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-12
      • 1970-01-01
      相关资源
      最近更新 更多