javascript - Phonegap 简单 javascript 未运行(onClick 问题?) - Android 和 iOS

标签 javascript android ios cordova

当我在 Firefox 中测试时,这似乎工作正常。一旦我通过phonegap安装它,它就不会。我已经删除了尽可能多的代码,以使其尽可能简单。

为什么当我按下按钮时,会出现alert('ok');在 iOS 或 Android 上不会发生吗?

我的代码如下。

谢谢

    <!DOCTYPE html> 
<html> 
    <head> 
    <title>XYZ</title> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="stylesheet" href="http:code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" />
    <script src="http:code.jquery.com/jquery-1.7.1.min.js"></script>
    <script src="http:code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script>

    <script>
    function saveResponseToLocalStorage(){
        alert('ok');
    }
    </script>


    </head> 
<body> 

<div data-role="page">

    <div data-role="header">
        <h1>XYZ</h1>
    </div><!-- /header -->
    <div data-role="content">   
        <h2>Search By Postcode + Name</h2>  
        <form>
            <label for="name">Name:</label>
            <input type="text" name="text" id="text" value="">
            <br/>
            <label for="city">Post Code:</label>
            <input type="text" name="postcode" id="postcode" value="">
            <br/>
            <button onclick="saveResponseToLocalStorage()">Search</button>  
        </form>
    </div><!-- /content -->
</div><!-- /page -->

</body>
</html>

最佳答案

尝试将其放在警报之前

navigator.notification.alert("ok");

关于javascript - Phonegap 简单 javascript 未运行(onClick 问题?) - Android 和 iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18293985/

相关文章:

javascript - 在 React 中,什么会调用高阶组件和 redux-thunk 之类的返回函数?

javascript - 在循环中使用 javascript 闭包作为上下文

Android Admob 无法加载广告 : 0 - Error waiting for future TimeoutException Problem with OREO only

android - 使用后置摄像头计算场景亮度

ios - GestureRecognizer 不适用于 TableView

javascript - 在工具提示中隐藏长表格单元格内容

javascript - 按字段名从数组中删除元素

java - JorgeCastilloPrz 的 AndroidFillableLoaders 库 - SVGPath 问题

iphone - 如何将 plist 保存到 NSUserDefaults

javascript - 触摸设备中的 VideoJS 播放器覆盖按钮