1.核心技术和例子
http://developer.android.com/resources/articles/using-webviews.html
Using WebViews
它介绍了 javascript <->java,之间的相互调用方法,简单但是所有类似架构的基础。a:javascript调用java
First, JavaScript running inside the WebView can call out to code in your Activity. You can use this to have your JavaScript trigger actions like starting a new activity, or it can be used to fetch data from a database orContentProvider
. The API for this is very simple: just call theaddJavascriptInterface()
method on your WebView. You pass an object whose methods you want to expose to JavaScript and the name to use when making calls. You can see the exact syntax in WebViewDemo. java. Here we are making our DemoJavascriptInterface object available to JavaScript where it will be called "window.demo".
b: java 调用 javascript
Second, your Activity can invoke JavaScript methods. All you have to do is call theloadUrl
method with the appropriate JavaScript call:
mWebView.loadUrl("javascript:wave()");
2.非常详细的一个webview的例子WebView Demo!!!
http://eagle.phys.utk.edu/guidry/android/webviewdemo.html
3.android的webview中javascript执行alert无效?
3.android的webview中javascript执行alert无效?
需要使用WebChromeClient
:
webview.setWebChromeClient(new WebChromeClient());
甚至还能覆盖alert
的实现:
str--要显示在消息对话框中的文本
webview.setWebChromeClient(new WebChromeClient() { @Override public boolean onJsAlert(WebView view, String url, String message, JsResult result) { //Required functionality here return super.onJsAlert(view, url, message, result); } }); 相关参考:JavaScript alert()函数详细使用说明 http://www.php100.com/html/webkaifa/javascript/2010/1009/6482.html
alert--弹出消息对话框,并且alert消息对话框通常用于一些对用户的提示信息。
JavaScript alert()函数
alert--弹出消息对话框(对话框中有一个OK按钮)
alert,中文"提醒"的意思
alert函数语法
alert(str);
alert函数说明
alert消息对话框通常用于一些对用户的提示信息,例如在表单中输入了错误的数据时。
提示:消息对话框是由系统提供的,因此样式字体在不同浏览器中可能不同。
提示:消息对话框是排它的,也就是在用户点击对话框的按钮前,不能进行任何其它操作。
提示:消息对话框通常可以用于调试程序。
示例
alert("Hellodreamdu!");
- alert('Welcometo<br/>dreamdu!');
- alert('Welcometo\ndreamdu!');
注意上面的第二个与第三个例子,只有第三个例子才能实现换行,参考ASCII码表,使用HTML中的br标签无法换行。
2. 非常好的HTML 和HTML DOM学习资料
http://www.w3school.com.cn/htmldom/dom_obj_window.asp
http://www.w3school.com.cn/tags/tag_comment.asp
http://www.htmlcodetutorial.com/search.html?cx=partner-pub-6155056320102818%3Aomfj3qxh2mm&cof=FORID%3A10&ie=ISO-8859-1&q=a&sa=Site+Search
http://www.cnblogs.com/caishuhua226/archive/2012/03/20/2408165.html