更改 Javascript 警报的标题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4172022/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 11:14:06  来源:igfitidea点击:

Change Title of Javascript Alert

javascript

提问by Sweety

How can i change the title of javascript alert popup ?

如何更改 javascript 警报弹出窗口的标题?

回答by Nick Craver

You can't, this is determined by the browser, for the user's safety and security. For example you can't make it say "Virus detected" with a message of "Would you like to quarantine it now?"...at least not as an alert().

你不能,这是由浏览器决定的,为了用户的安全和保障。例如,您不能用“您现在要隔离它吗?”的消息说“检测到病毒”……至少不能作为alert().

There are plenty of JavaScript Modal Dialogs out there though, that are farmore customizable than alert().

有大量的JavaScript模态对话框在那里,虽然,这是远远超过自定义alert()

回答by Frédéric Hamidi

As others have said, you can't do that either using alert()or confirm().

正如其他人所说,您不能使用alert()或来做到这一点confirm()

You can, however, create an external HTML document containing your error message and an OKbutton, set its <title>element to whatever you want, then display it in a modal dialog box using showModalDialog().

但是,您可以创建一个包含错误消息和OK按钮的外部 HTML 文档,将其<title>元素设置为您想要的任何内容,然后使用showModalDialog()将其显示在模式对话框中。

回答by cdhowie

Simple: you can't.

很简单:你不能。

回答by Guffa

You can't. The alert is a simple popup where you only can affect the content text.

你不能。警报是一个简单的弹出窗口,您只能在其中影响内容文本。

If you want to change anything else, you have to use a different way of creating a popup.

如果您想更改其他任何内容,则必须使用不同的方式来创建弹出窗口。

回答by sushil bharwani

you cant do this. Use a custom popup. Something like with the help of jQuery UI or jQuery BOXY.

你不能这样做。使用自定义弹出窗口。类似于 jQuery UI 或 jQuery BOXY 的帮助。

for jQuery UI http://jqueryui.com/demos/dialog/

对于 jQuery UI http://jqueryui.com/demos/dialog/

for jQuery BOXY http://onehackoranother.com/projects/jquery/boxy/

对于 jQuery BOXY http://onehackoranother.com/projects/jquery/boxy/

回答by Omiod

It's not possible, sorry. If really needed, you could use a jQuery plugin to have a custom alert.

这是不可能的,对不起。如果确实需要,您可以使用 jQuery 插件来自定义警报。