2011-12-07 13 views
9

soy nuevo en phonegap y quiero desarrollar una aplicación de phonegap para android .. quiero darle alguna función al botón hacer clic en mi html .. he probado este código pero no funciona:¿Cómo agregar la función al botón en phonegap?

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

ha alguien sabe cómo resolver mi problema ?? gracias delante ..

Respuesta

13

Sólo hay que poner el cierre "(comillas dobles) en el cuerpo de la etiqueta

<body onload="init();"> 
+6

lo odio cuando hago eso :) – ToddBFisher

Cuestiones relacionadas