Quantcast
Channel: Appcelerator Developer Center Q&A Tag Feed (webview)
Viewing all articles
Browse latest Browse all 680

WebView: can't use evalJS

$
0
0

I can't use evalJS, this is my test app:

index.js

var web = Ti.UI.createWebView({
    enableZoomControls:false,
    disableBounce:true,
    willHandleTouches:false,
    touchEnabled:false,
    url:'test.html'
});
 
web.addEventListener('load',function(e) {
 
    console.log('update value');
 
    web.evalJS('top();');
});
 
$.index.add(web);
$.index.open();
lib/index.html
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta charset="utf-8">
        <title>JS Test</title>
    </head>
    <body style='margin:30px 0;text-align:center;background:#ccc;'>
 
        <div id='top'>----</div>
 
        <script>
            var top = function() {
                document.getElementById("top").innerHTML = "WORKS";
            };
        </script>
    </body>
</html>
console logs
[INFO] :   update value
[DEBUG] :  New scheme: <NSMutableURLRequest: 0x7fe971737dd0> { URL: file:///Users/ricardo/Library/Developer/CoreSimulator/Devices/CAEFDE57-7E6F-47F0-A9E1-446CF0F66DE6/data/Containers/Bundle/Application/716EC644-7C07-44B7-A2DE-A2A7B613444A/test.list.app/test.html }
[DEBUG] :  Loading: /Users/ricardo/Library/Developer/CoreSimulator/Devices/CAEFDE57-7E6F-47F0-A9E1-446CF0F66DE6/data/Containers/Bundle/Application/716EC644-7C07-44B7-A2DE-A2A7B613444A/test.list.app/test.html, Resource: test_html

Viewing all articles
Browse latest Browse all 680


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>