请检查我的代码:
<!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">
function onLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
}
function onDeviceReady() {
// Register the event listener
document.addEventListener("searchbutton", myfunction, false);
}
function myfunction() {
alert("hello");
}
</script>
</head>
<body onload="onLoad()">
</body>
</html>
我想要alert("hello");
,但它不起作用。我刚刚开始使用PhoneGap-2.9.0的Android应用程序,我遇到了很多问题。请帮忙。
修改
<!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 src="js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="phoneGap.js"></script>
<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() {
// Register the event listener
alert('this is device ready function');
document.addEventListener("click", myfunction, false);
}
function myfunction() {
alert("hello");
}
</script>
</head>
<body onload="onLoad()">
<a href="javascript:;" onClick="myfunction();">Click 1</a>
<a href="javascript:;" onClick="onDeviceReady();">Click 2</a>
</body>
</html>
请检查上面的代码并告诉我为什么Click 2
现在正在模拟器中工作?
答案 0 :(得分:0)
更改
68.9.161.152 - - [13/Dec/2015 05:27:24] "GET /mp4/?filename=video/How_To_Shave_Your_Beard_Like_A_Man.mp4 HTTP/1.1" 200 -
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "/home/www/env/local/lib/python2.7/site-packages/werkzeug/serving.py", line 653, in inner
fd=fd).serve_forever()
File "/home/www/env/local/lib/python2.7/site-packages/werkzeug/serving.py", line 505, in serve_forever
HTTPServer.serve_forever(self)
File "/usr/lib/python2.7/SocketServer.py", line 238, in serve_forever
self._handle_request_noblock()
File "/usr/lib/python2.7/SocketServer.py", line 297, in _handle_request_noblock
self.handle_error(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock
self.process_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request
self.finish_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python2.7/SocketServer.py", line 649, in __init__
self.handle()
File "/home/www/env/local/lib/python2.7/site-packages/werkzeug/serving.py", line 217, in handle
rv = BaseHTTPRequestHandler.handle(self)
File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
self.handle_one_request()
File "/home/www/env/local/lib/python2.7/site-packages/werkzeug/serving.py", line 252, in handle_one_request
return self.run_wsgi()
File "/home/www/env/local/lib/python2.7/site-packages/werkzeug/serving.py", line 194, in run_wsgi
execute(self.server.app)
File "/home/www/env/local/lib/python2.7/site-packages/werkzeug/serving.py", line 185, in execute
write(data)
File "/home/www/env/local/lib/python2.7/site-packages/werkzeug/serving.py", line 166, in write
self.wfile.write(data)
到
document.addEventListener("click", myfunction, false);