如何更改'alert'的默认标题

时间:2023-02-05 18:05:37

I am trying to use the alert method, so the native iOS like alertView will popout. Everything works fine, and the alert gets displayed. But the Heading of the Alert is always index.html.

我正在尝试使用alert方法,因此将弹出像alertView这样的原生iOS。一切正常,警报会显示出来。但警报的标题始终是index.html。

How can i edit the heading of the alert method

如何编辑警报方法的标题

2 个解决方案

#1


21  

You'll want to use navigator.notification.alert() from the PhoneGap API instead. It will allow you to set a title on your alert box.

您将需要使用PhoneGap API中的navigator.notification.alert()。它允许您在警报框中设置标题。

#2


2  

If you don't want to refactor your code, you can override the alert() method with a notification :

如果您不想重构代码,可以使用通知覆盖alert()方法:

window.alert = function (txt) {
   navigator.notification.alert(txt, null, "Alert", "Close");
}

You can custumize the window title : "Alert, and the close button : "Close"

您可以使用窗口标题:“警报”和“关闭”按钮:“关闭”

#1


21  

You'll want to use navigator.notification.alert() from the PhoneGap API instead. It will allow you to set a title on your alert box.

您将需要使用PhoneGap API中的navigator.notification.alert()。它允许您在警报框中设置标题。

#2


2  

If you don't want to refactor your code, you can override the alert() method with a notification :

如果您不想重构代码,可以使用通知覆盖alert()方法:

window.alert = function (txt) {
   navigator.notification.alert(txt, null, "Alert", "Close");
}

You can custumize the window title : "Alert, and the close button : "Close"

您可以使用窗口标题:“警报”和“关闭”按钮:“关闭”