Bly*_*ynn 11 javascript iphone ios cordova
我的应用程序有几个JS警报,似乎总是显示页面名称.
的index.html
有没有办法将index.html更改为我的应用程序名称或自定义文本.
例:
My App // Which replaces .index.html
alert("I am an alert box!");
Run Code Online (Sandbox Code Playgroud)
Zor*_*ayr 15
为了能够在桌面浏览器和PhoneGap应用程序上进行测试,我建议使用动态方法:
function showMessage(message, callback, title, buttonName) {
title = title || "default title";
buttonName = buttonName || 'OK';
if(navigator.notification && navigator.notification.alert) {
navigator.notification.alert(
message, // message
callback, // callback
title, // title
buttonName // buttonName
);
} else {
alert(message);
callback();
}
}
Run Code Online (Sandbox Code Playgroud)
Dre*_*man 14
像Simon说的那样查看通知它是phonegap API的一部分.
你这样称呼它 -
带选项的通知:
navigator.notification.confirm(
"This is my Alert text!",
callBackFunction, // Specify a function to be called
'Alert Title',
["Ok", "Awesome"]
);
function callBackFunction(b){
if(b == 1){
console.log("user said ok");
}
else {
console.log("user said Awesome");
}
}
Run Code Online (Sandbox Code Playgroud)
一个简单的通知 -
navigator.notification.alert(
"This is my Alert text!",
callBackFunctionB, // Specify a function to be called
'Alert Title',
"OK"
);
function callBackFunctionB(){
console.log('ok');
}
Run Code Online (Sandbox Code Playgroud)
希望有所帮助!