当前位置: 动力学知识库 > 问答 > 编程问答 >

Phonegap simple javascript not running (onClick issue?) - Both Android and iOS

问题描述:

This seems to work fine when I test in firefox. As soon as I install it through phonegap, it doesn't. I have removed as much code as I can to make it as simple as I can.

Why when I press the button, does the alert('ok'); not happen on iOS or Android?

My code is below.

Thanks,

 <!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>

网友答案:

Try to put this before the alert

navigator.notification.alert("ok");
分享给朋友:
您可能感兴趣的文章:
随机阅读: