我是phonegap和使用phonegap iOS应用程序的新手。我正在尝试从HTML类调用JavaScript函数,但奇怪的是它没有被调用。 Android代码库同样适用。
这是我的HTML类代码:
<script language="javascript" type="text/javascript"></script>
<!--<script type="text/javascript" charset="utf-8" src="js/cordova.js"></script>-->
<script type="text/javascript" charset="utf-8" src="pages/VoiceRecord.js"></script>
<div data-role="page" id="VoiceRecord">
<div data-role="header" data-position="fixed" class="header">
<a onclick='OpenLeftPanel();' data-theme="a" ><img class="iconimg" src="images/lines_menu.png" data-theme="none"/></a>
<img class="headlogo" src="images/logo_inner.png"/>
<a onclick='OpenRightPanel();' data-theme="none" ><img class="iconimg" src="images/profile_menu.png"/></a>
</div>
<div data-role="main" class="ui-content" id="VoiceRecordnotes">
<label id="labe_id">Recording Audio... </label><label id="audio_position"> </label>
<button id="media" data-inline="true" class="ui-btn-a ui-mini" type="button" value="" onclick="recordAudio()">Record</button>
<button id="stop" data-inline="true" class="ui-btn-a ui-mini" type="button" value="" onclick="stop()" disabled>Stop Recording</button>
</div>
</div>
<script>
function recordAudio(){
alert("indside recordAudio in .htm");
document.getElementById("labe_id").style.visibility="visible";
document.getElementById("audio_position").style.visibility="visible";
startAudioRecording();
$('#media').attr('disabled', 'disabled');
$("#stop").removeAttr('disabled');
}
function stop(){
alert("inside stop in .htm");
$('#stop').attr('disabled', 'disabled');
$("#media").removeAttr('disabled');
stopAudioRecording();
navigate('helpline');
}
</script>
我的JS类代码是:
function startAudioRecording(){
alert ("recordAudio in js");
var user = getCurrentUser();
alert("user" +user);
var username=user.userId;
var phoneno=user.phone_no;
cordova.exec(succesCallBack, erorCallBack,'AudioRecording','recordAudio',[{"username":username,"phoneno":phone_no}]){
};
我已将我的JS文件包含在index.html中。当我在浏览器中运行我的HTML文件并尝试跳转到我的JS文件时,它会在safari中打开一个空白文件。
有人能引导我吗?