Android Question Javascript cann't running in webview

jinyistudio

Well-Known Member
Licensed User
Longtime User
following html code i could opening(see the svg) and running in the firefox of window7.
While i open it with webview in B4A. I just see svg but updateTime isn't running.

P.S
attachied file is the HTML files !

B4X:
<script language='javascript' type='text/javascript'>

  var container = document.getElementById('container');
  var graphic = archer.create(container);

  graphic.loadUrl('archer.graphic.svg', 'archer.config.json');

  graphic.on('ready', function() {
    graphic.view.zoomToFit();
    setInterval(updateTime, 10);
  });

  function updateTime() {

    var now = new Date();

    var seconds = now.getSeconds();
    var minutes = now.getMinutes() + (seconds / 60);
    var hours = now.getHours() + (minutes / 60);

    graphic.setValue('hours', hours);
    graphic.setValue('minutes', minutes);
    graphic.setValue('seconds', seconds);
  }
</script>

B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("page1")
    'If page <> "" Then
    Page1.Initialize("page1")
    Activity.AddView(Page1, 0dip, 0dip, 100%x,100%y)  
  
    Page1.LoadURL("file:///android_asset/" & page & "clock.html")
    Page1.JavaScriptEnabled=True
   'End If
End Sub
 

Attachments

  • Files.zip
    36.5 KB · Views: 223
Last edited:

icefairy333

Active Member
Licensed User
Longtime User
example.html in the chrome
The graphic files could not be loaded
Please note that this example may only work when served through a web server. The example code needs to dynamically load files which for security reasons is not allowed when serving from the file system.
clock.html in the chrome
aaa.png
 
Upvote 0
Top