写了个例子,总是不对,点击menubutton的时候不起作用,纠结了好久,求高手解答~~
以下是我的代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="target-densityDpi=device-dpi, width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"/>
<title>jQuery Mobile Web 应用程序</title>
<link href="jquery-mobile/jquery.mobile-1.0a3.min.css" rel="stylesheet" type="text/css"/>
<script src="jquery-mobile/jquery-1.5.min.js" type="text/javascript"></script>
<script src="jquery-mobile/jquery.mobile-1.0a3.min.js" type="text/javascript"></script>
<script src="phonegap.js" type="text/javascript"></script>
</head>
<body>
<div data-role="page" class="page">
<div data-role="header" id="header"><h1>第 1 页</h1></div>
<div data-role="content" id="wrapper">
</div>
<div data-role="footer" id="footer">
<h4>页面脚注</h4>
</div>
</div>
</body>
<script type="text/javascript">
// 等待加载PhoneGap
document.addEventListener("deviceready", onDeviceReady, false);
// PhoneGap加载完毕
function onDeviceReady() {
//按钮事件
alert("test");
document.addEventListener("menubutton", eventMenuButton, false); //菜单键
}
//菜单键
function eventMenuButton(){
alert('点击了 菜单 按钮!');
}
</script>
</html>
以下是我的js结构:
纠结了不是一天两天了,求高手解答!!!
缺乏一个触发事件,比如<body onload="onload()">.....