我正在尝试编写用于在 phonegap 中发送短信的代码。我已经编写了代码。但是我收到了错误:未捕获的类型错误:无法读取未定义的属性“短信”。以下是我的代码。请指教。
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content= "width=device-width; height=device-height; user-scalable=no">
<link rel="stylesheet" type="text/css" href= "jquery.mobile-1.0b3.min.css">
<script src="jquery-1.6.min.js" type= "text/javascript"></script>
<script src="jquery.mobile-1.0b3.min.js" type="text/javascript"> </script>
<script src="cordova-2.3.0.js" type="text/javascript"> </script>
<Script src="smsplugin.js" type="text/javascript" ></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
</head>
<script type="text/javascript">
//document.addEventListener("deviceready", onDeviceReady, false);
//function onDeviceReady () {
function Message() {
alert("hi");
alert('Phone: ' + $('#phone').val() + ' Message: ' + $('#message').val());
window.plugins.sms.send($('#phone').val(),
$('#message').val(),
function () {
alert('Message sent successfully');
},
function (e) {
alert('Message Failed:' + e);
}
);
}
</script>
<body>
<div id="startPage" data-role="page" data-theme="a">
<a href="home.html" data-role="button" data-transition="turn" data-inline="true" data-icon="back">Back</a>
<div data-role="header">
<h1>SMS Demo</h1>
</div>
<div data-role="content">
<label for="phone">Recipient Number:</label>
<input type="tel" id="phone" name="phone" placeholder="SMS Number"/>
<label for="message">Message:</label>
<textarea id="message" name="message" placeholder="Type your text message here...........(Eg- Hi Dad, I am in an emergency...please help me.I am located at (GPS Location))"></textarea>
<!--<a href="#" id="sms" data-role="button" onclick="Message()">Send</a></br>-->
<button id= "sendbutton" onClick="Message()">Send</button>
</div>
</div>
</body>
</html>