html - My first APP, Cordova and iOS -
i'm trying simple app phonegap (cordova 3.0.0) on ios. here index.html:
<!doctype html> <head> <title>app</title> <script type="text/javascript" charset="utf-8" src="cordova.js"></script> <script type="text/javascript" charset="utf-8"> function onload() { document.addeventlistener("deviceready", ondeviceready, false); } function ondeviceready() { alert("hello!"); } </script> </head> <body onload="onload()"> hola <br /> <a href="http://www.google.es" target="_blank"> pulsame </a> <div id="idi"></div> </body> </html>
but nothing happens. device never ready, never shows alert. think problem cordova.js, can't find problem (the proyect created fine , runs).
any help?
don't use onload function attach listener. instead attach listener, use ondeviceready function if onload. should this:
<!doctype html> <head> <title>smartpol</title> <script type="text/javascript" charset="utf-8" src="cordova.js"></script> <script type="text/javascript" charset="utf-8"> document.addeventlistener("deviceready", ondeviceready, false); function ondeviceready() { alert("hello!"); } </script> </head> <body> hola <br /> <a href="http://www.google.es" target="_blank"> pulsame </a> <div id="idi"></div> </body> </html>
also, if want attach other event listeners can after ondeviceready has fired.
Comments
Post a Comment