Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Title of Javascript Alert [duplicate]

Tags:

javascript

How can i change the title of javascript alert popup ?

like image 455
Sweety Avatar asked Nov 13 '10 10:11

Sweety


People also ask

How do I change the title of an alert () box in JavaScript?

It's not possible to edit a JavaScript alert box title due to security issues. Still, to edit an alert box to work it all web browsers, use custom JavaScript Modal Dialogs or jQuery plugins.

How do I change the message title alert?

You can't change the title for the alert message but you can over ride the window. alert method and set the custom title for the alert.

Can we customize alert box in JavaScript?

The standard alert box in JavaScript does not provide the option to apply CSS. To style your alert box, you need to create a custom one first. The custom alert box will be created using jQuery and styles will be applied to CSS.

What happens when JavaScript runs the alert () function?

One useful function that's native to JavaScript is the alert() function. This function will display text in a dialog box that pops up on the screen. Before this function can work, we must first call the showAlert() function. JavaScript functions are called in response to events.


2 Answers

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().

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

like image 162
Nick Craver Avatar answered Oct 08 '22 07:10

Nick Craver


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

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

like image 23
Frédéric Hamidi Avatar answered Oct 08 '22 08:10

Frédéric Hamidi