appMobi onClick不起作用

时间:2013-01-04 10:22:45

标签: javascript html appmobi

我是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>

1 个答案:

答案 0 :(得分:1)

最后,我找到了解决方案! 而不是onclick="myfunction"您必须使用ontouchstart="myfunction"
如果有人能告诉我原因,那会很好。

相关问题