I am trying to get date and time using javascript in a web view, but it returns baseUrl
instead of date/time. Code:
webView.loadDataWithBaseURL("", htmlstring, "text/html", "utf-8", "");
webView.setWebChromeClient(new WebChromeClient());
Code to get date/time :
<script type="text/javascript">
var d=new Date().getTime();
console.log("Get Date :: ",d);
</script>
Output in LogCat :
Get Date :: blank 1
如果尚未这样做,则需要通过以下方式启用JavaScript:
webView.getSettings().setJavaScriptEnabled(true);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.