I am trying to load the html file into Webview downloaded from server. The html file contains the javascript and it is saved in application cache folder. The Webview shows only blank white screen and in log i see this error.
Uncaught ReferenceError: refresh_rates is not defined at file:///data/data/com.app.package/files/aboutus.html:1
Html file source:
<html>
<head>
<style type="text/css">
<!--
body { margin: 0px 0px 0px 0px; }
-->
</style>
<script>
<!--
var intervalID;
function setUpdateRates()
{
refresh_rates ();
intervalID = setInterval(refresh_rates, 50000);
}
function refresh_rates () {
var url ='http://www.google.com';
//alert(url);
document.getElementById('rates').src = url;
}
-->
</script>
</head>
<body onload="setUpdateRates();">
<iframe name="rates" id="rates" src="" width="100%" height="100%" frameborder="0" marginwidth="0" marginheight="0" scrolling="auto"></iframe>
</body>
</html>
Webview:
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setDomStorageEnabled(true);
mWebView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
mWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
Loading html file in Webview:
mWebView.loadUrl(mFileLoader.getFilePath(CACHE_HTML));
Please let me know where i am going wrong.
It seems the problem is with commenting tags. So after removing this
<!--,-->and//tags it got worked.