How to add function on button in phonegap?

孤街浪徒 提交于 2019-12-10 03:26:47

问题


I'm new to Phonegap and I want to develop a Phonegap application for Android.. I want to give some function on button click on my html.. I've tried this code but it does not work:

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");
}

Does anyone know how to solve my problem?


回答1:


Just put the closing "(double quotes) in the body tag

<body onload="init();">


来源:https://stackoverflow.com/questions/8409709/how-to-add-function-on-button-in-phonegap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!