我是新的phonegap,我想开发一个Android的phonegap应用程序..我想给我的HTML上的按钮点击一些功能..我已经尝试了这个代码,但它不起作用:
的index.html
<!DOCTYPE HTML>
<html>
<head>
<title>PhoneGap</title>
<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
<script type="text/javascript" charset="utf-8" src="mycode.js"></script>
</head>
<body onload="init();>
<h1>Hello World</h1>
<form>
<input type="button" value="Click me" onclick="msg()" />
</form>
</body>
</html>
mycode.js
function init() {
// the next line makes it impossible to see Contacts on the HTC Evo since it
// doesn't have a scroll button
// document.addEventListener("touchmove", preventBehavior, false);
document.addEventListener("deviceready", deviceInfo, true);
}
function msg()
{
alert("button clicked");
}
有谁知道如何解决我的问题?谢谢你..
答案 0 :(得分:13)
只需在主体标记中加上“(双引号)
即可<body onload="init();">