I am trying to load a local HTML file from assets folder in webview. I can get the HTML file to load in webview, but the html file relies on one external .js file to do some calculations. When I am clicking the functions of the calculator in webview, it doesn't do anything (it's not using the .js file).
I changed path in HTML to match the path to the .js file:
<script language="JavaScript" src="file:///android_asset/convert2.js" type="text/javascript"></script>
but it's still not working. Any ideas?
here's the HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="content-type">
<script language="JavaScript" src="file:///android_asset/convert2.js" type="text/javascript"></script>
<link href="au_files/style.css"
rel="stylesheet" type="text/css">
<link href="au_files/print.css"
rel="stylesheet" type="text/css"
media="print">
</head>
<body>
<center>
<table id="mainbg"
border="0" cellpadding="1" cellspacing="0"
width="692">
<tbody>
<tr>
<td>
<!-- The above table places the 1 pixel gray outline around the whole page -->
<table border="0" cellpadding="0"
cellspacing="0" width="690">
<tbody>
<tr>
<td valign="top"
width="500">
<table style="width: 687px; height: 384px;"
border="0" cellpadding="10"
cellspacing="0">
<tbody>
<tr>
<td class="content"
valign="top" width="500">
<div align="center">
<h1> <strong><span>Astronomical
Unit
Conversion</span></strong>
</h1>
</div>
<br>
<form name="MainForm"
align="center">
<div align="center">
<center>
<table border="0">
<tbody>
<tr>
<td style="text-align: center;"
colspan="2"><strong>Convert:</strong>
<input name="what"
size="15" onfocus="javascript:resetanswer();"
onkeypress="microsoftKeyPress();"
type="text"> </td>
</tr>
<tr>
<td align="center">From:<br>
<select name="from"
size="10" onchange="javascript:myCon();">
<option selected="selected"
value="149597870691">astronomical
unit [1996]</option>
<option value="1000">kilometer</option>
<option value="299792458">light
second</option>
<option value="299792458 * 60">light
minute</option>
<option value="299792458 * 60 * 60">light
hour</option>
<option value="299792458 * 60 * 60 * 24">light
day</option>
<option value="299792458 * 60 * 60 * 24 * 365.25">light
year [Julian]</option>
<option value="299792458 * 31556925.9747">light
year
[tropical]</option>
<option value="299792458 * 60 * 60 * 24 * 365">light
year
[traditional]</option>
<option value="149597870691 * 206264.8">parsec</option>
<option value="1">meter</option>
<option value="1609.344">mile</option>
</select>
</td>
<td align="center">To:<br>
<select name="to"
size="10" onchange="javascript:myCon();">
<option selected="selected"
value="149597870691">astronomical
unit [1996]</option>
<option value="1000">kilometer</option>
<option value="299792458">light
second</option>
<option value="299792458 * 60">light
minute</option>
<option value="299792458 * 60 * 60">light
hour</option>
<option value="299792458 * 60 * 60 * 24">light
day</option>
<option value="299792458 * 60 * 60 * 24 * 365.25">light
year [Julian]</option>
<option value="299792458 * 31556925.9747">light
year
[tropical]</option>
<option value="299792458 * 60 * 60 * 24 * 365">light
year
[traditional]</option>
<option value="149597870691 * 206264.8">parsec</option>
<option value="1">meter</option>
<option value="1609.344">mile</option>
</select>
</td>
</tr>
<tr>
<td colspan="2"
align="center">
<input value="CONVERT!"
name="Go" onclick="javascript:myCon();" type="button"></td>
</tr>
<tr>
<td colspan="2" align="left"><strong>Results: </strong><br>
<input name="answer" size="70" style="word-spacing: -0.10em" readonly="readonly"
type="text"></td>
</tr>
</tbody></table>
</center></div>
</form>
<!-- Center Bottom -->
</td></tr></tbody></table></td>
</tr>
</tbody></table></td>
</tr>
</tbody></table>
</center>
</body></html>
heres my android code to load the webview but i'm not sure if that's helpful because the webview is loading, it's just that the HTML file is not properly using the .js file once it's loaded.
WebView lWebView = (WebView)findViewById(R.id.webView1);
lWebView.loadUrl("file:///android_asset/au.html");