I'm making a webapp and I'm using jQuery.
I've made a simple android application with a WebView in it, and I load my url: www.mydomain.com
In mydomain.com I have:
<script src="js/jquery_1.4.2_min.js"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
alert("Hii!!!!");
});
</script>
If I visit mydomain from the browser, the alert shows fine. But If I visit from my native application, it doesn't show. What can I do?
Is JavaScript enabled in your webview...?
WebView.getSettings().setJavaScriptEnabled(true);
Old question, but thought i'd add my 2cents anyway.
Javascript alerts do work in a webview, but you have to set the Web chrome client first.
webView.setWebChromeClient(new WebChromeClient())
I'm no expert with Android native but we have just developed an app using jQuery based site within a webview. You need setJavaScriptEnabled(true) in your activity class and jQuery runs jsut fine. However your example with alert('Hi'); will not work because Android webviews don't support alerts by default. It can be enabled with a little googling... http://lexandera.com/2009/01/adding-alert-support-to-a-webview/
Alternatively we added a custom showAlert js function to display pretty user notifications.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With