function alertDismissed(tag_name) { // This is callback function
tag_name.focus();
}
function showAlert(msg, callbackfn) {
navigator.notification.alert(
'Please enter email', // message
alertDismissed:'callbackfn', // callback
'App name', // title
'Ok' // buttonName
);
}
我想将参数传递给alertDismissed()
函数。我这样称呼它:
UserName=document.getElementById("name-txt").value;
if(UserName == "" || UserName == null)
{
showAlert("Please enter email","name-txt");
}
实际上,点击“确定”按钮后我想要焦点。我怎么能这样做?
答案 0 :(得分:1)
你可以这样做
function showAlert(msg, callbackfn) {
navigator.notification.alert(
'Please enter email', // message
function () {
console.log(callbackfn);
}, // callback
'App name', // title
'Ok' // buttonName
);
}