我对 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>
最佳答案
终于找到解决办法了!
您必须使用 ontouchstart="myfunction"
而不是 onclick="myfunction"
!
如果有人能告诉我原因就好了。
关于javascript - appMobi onClick 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14155247/