WebView 工作记录

来源:互联网 发布:ubuntu不支持vim 编辑:程序博客网 时间:2024/06/16 02:55

为移动设备而改造网页

http://newhtml.net/modify-page-for-mobile/

http://www.html5rocks.com/en/mobile/mobifying/

======================

关于link .css或.js

在pc上第二次请求服务器会返回304

在webview跟本不会发起第二次请求。直接会读取缓存。


Tool to see android database, tables and data

http://stackoverflow.com/questions/2149438/tool-to-see-android-database-tables-and-data

There is a tool (sqlite3) installed on the phone itself. You should be able to do this if you have ADB installed on your machine & your phone is connected or currently being emulated.

Find the database files:

adb shell find /data -name *.db/data/data/com.google.android.apps.maps/databases/search_history.db/data/data/com.qo.android.htc/databases/webview.db/data/data/com.qo.android.htc/databases/webviewCache.db/data/data/com.layar/databases/layar.db
或者select your database (Into Androd --> File Explorer ),You will get an option as "pull a file from device", click on it. 

Open a database using the sqlite tool:

C:\> adb shell # sqlite3 /data/data/com.google.android.youtube/databases/history.dbSQLite version 3.5.9Enter ".help" for instructionssqlite> .tablesandroid_metadata  suggestionssqlite> .schema suggestionsCREATE TABLE suggestions (_id INTEGER PRIMARY KEY,display1 TEXT UNIQUE ON CONFLICT REPLACE,display2 TEXT,query TEXT,date LONG);sqlite> select * from suggestions;2|randy pausch last lecture|Results for "randy pausch last lecture"|randy pausch last lecture|1264159994987


或者sqlite database browser could also be helpful, though you need to pull a copy of the database from the device as explained before and work on that copy that can be restored later on.


在android 4.0 webview 使用loadData 会出现中文乱码, 这个时候要使用loadDataWithBaseURL方法

//loadData(html, "text/html", "UTF-8");
loadDataWithBaseURL(null, html, "text/html", "UTF-8", null);



注意的问题:

android 4.0的特殊性---参数

<img src="images/laba.png"><img src="images/laba.png?v=2">

当加载本地页面(如放在assets下面),在4.0的webview 上第二张图片不能显示,加载本地文件不能带参数

android 4.0的特殊性---特殊符号

4.0对于页面里的特殊符号,可能也会导致无法解析,使js方法不能执行完成。



js方法里的换行

webview对于js方法里的换行无法解析!



ios的uiwebview,meta里用逗号,而不能用分号

<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />


android 2.2的特殊性---window.demo.fun()

android客户端方法String fun();

js调用,返回的是Object类型,而不是String,这个问题出现的android2.2(2.3及以上是ok的)的机型上。

解决办法:window.demo.fun() + ""

s




s



s