我对appMobi、HTML和JavaScript都是新手。我想做的唯一一件事就是我有一个带有onClick方法的按钮,这个方法应该可以做任何事情。我已经定义了一个脚本,我有一个按钮,但是方法没有被调用。有人能告诉我为什么吗?appMobi提供的示例并没有做任何不同的事情-我认为。下面是我的代码:
<head>
<!-- the line below is required for access to the appMobi JS library -->
<script type="text/javascript" charset="utf-8" src="http://localhost:58888/_appMobi/appmobi.js"></script>
<script type="text/javascript" language="javascript">
// This event handler is fired once the AppMobi libraries are ready
function onDeviceReady() {
//use AppMobi viewport to handle device resolution differences if you want
//AppMobi.display.useViewport(768,1024);
//hide splash screen now that our app is ready to run
AppMobi.device.hideSplashScreen();
}
//initial event handler to detect when appMobi is ready to roll
document.addEventListener("appMobi.device.ready",onDeviceReady,false);
function myfunction(){
AppMobi.debug.log("test");
alert("Hallo Welt");
}
</script>
<script type="text/javascript">
function myfunction(){
AppMobi.debug.log("test");
alert("Hallo Welt");
}
</script>
</head>
<body >
<br>
<button onclick="myfunction();">MyButton</button>
</body>发布于 2013-01-05 22:27:52
最后,我找到了解决方案!你必须使用ontouchstart="myfunction"而不是onclick="myfunction"!
如果有人能告诉我原因就太好了。
https://stackoverflow.com/questions/14155247
复制相似问题