如何在phonegap的按钮上添加功能? [英] How to add function on button in phonegap?

查看:224
本文介绍了如何在phonegap的按钮上添加功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

im新的phonegap和我想开发一个phonegap应用程序为Android ..我想给一些功能按钮点击我的html ..我已经尝试这个代码,但它不工作:

im new in 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 not works:

index.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

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

有任何人知道如何解决我的问题

has anyone know how to solve my problem?? thanks before..

推荐答案

只要在body标记中加上(双引号)
$ b

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

<body onload="init();">

这篇关于如何在phonegap的按钮上添加功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆