Hi everyone,
I'm new to Phonegap and have been struugling with a few strange things
before I can really get to work.
I started with trying to add a menubutton function to a project but I
kept getting stuck. (maybe also because I read that the menubutton
functionality was no longer in phonegap 0.9.5.1. Does anyone know why
that is? I tried re adding it myself)
But the biggest problem was that I can't get "deviceready" to be
called. For some reason phonegap.js was not being linked to my html
(that is what I figured anyway). After a lot of searching on the
internet and copypasting bits of script I suddenly got it working but
in a very strange way. I have linked phonegap.js twice in a bit
different way and this is the only way that works. I need to have both
these lines in my <head> for deviceready to be called:
<script type="text/javascript" charset="utf-8" src="./phonegap.js"></
script>
<script type="text/javascript" charset="utf-8" src="phonegap.js"></
script>
If I remove either of them nothing happens anymore.
I'm sure I'm overlooking something extremely obvious but I cant see it
(stared at it to long I guess ;) )
Does anyone have any idea what i'm doing wrong here? I appreciate the
effort. This is my full html:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "
http://www.w3.org/
TR/html4/strict.dtd">
<html>
<head>
<title>PhoneGap Device Ready Example</title>
<script type="text/javascript" charset="utf-8" src="./phonegap.js"></
script>
<script type="text/javascript" charset="utf-8" src="phonegap.js"></
script>
<script type="text/javascript" charset="utf-8">
// Call onDeviceReady when PhoneGap is loaded.
//
// At this point, the document has loaded but phonegap.js has
not.
// When PhoneGap is loaded and talking with the native device,
// it will call the event `deviceready`.
//
function onLoad() {
document.addEventListener("deviceready", onDeviceReady,
false);
alert('html loaded');
}
// PhoneGap is loaded and it is now safe to make calls PhoneGap
methods
function onDeviceReady() {
// Register the event listener
document.addEventListener("menubutton", onMenuKeyDown,
false);
alert('deviceready loaded');
}
// Handle the menu button
function onMenuKeyDown() {
//alert('menu key pressed');
}
</script>
</head>
<body onload="onLoad()">
</body>
</html>
thanks in advance,
Thijs