<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>JS WebView Demo</title>
<script language="JavaScript" type="text/javascript">
var ua = navigator.userAgent.toLowerCase();
if (/iphone|ipad|ipod/.test(ua)) {
alert("iphone");
}
else if (/android/.test(ua)) {
alert("android");
}
else{
alert("pc");
}
function callByNative(){
alert("欢迎 " + document.all.username.value + "!");
}
function qichaload(){
if (/iphone|ipad|ipod/.test(ua)) {
document.location = 'QiCha.load("http://www.baidu.com")';
}
else if (/android/.test(ua)) {
QiCha.load("http://www.baidu.com");
}
}
function qichaback(){
if (/iphone|ipad|ipod/.test(ua)) {
document.location = "QiCha.back";
}
else if (/android/.test(ua)) {
QiCha.back();
}
}
</script>
</head>
<body>
<div align="center">
<div style="text-align: center; width: 200px;">
<table cellpadding="5" cellspacing="5" border="0" align="center">
<tr>
<td align="left"><label for="u01">用户名:</label></td>
</tr>
<tr>
<td><input type="text" name="username" size="25" maxlength="50" id="u01" value="admin"></td>
</tr>
<tr>
<td align="left"><label for="p01">密码:</label></td>
</tr>
<tr>
<td><input type="password" name="password" size="25" maxlength="50" value="admin" id="p01"></td>
</tr>
<tr>
<td align="center"><input type="button" value="callByNative"
onclick="javascript:callByNative();"></td>
</tr>
<tr>
<td align="center"><input type="button" value="Qicha.back" onclick="javascript:qichaback();"></td>
</tr>
<tr>
<td align="center"><input type="button" value="Qicha.load(url)" onclick="javascript:qichaload();"></td>
</tr>
<tr>
<td align="center">JS WebView Demo, 版本: 0.0.1 </td>
</tr>
</table>
</div>
</div>
</body>
</html>