1

How do I display a simple alert in javascript without the title on top of the alert - Just a blank alert with just message.

vivianaranha
  • 2,781
  • 6
  • 33
  • 47
  • 2
    You don't use `alert()`, you display an appropriately styled `
    ` (or other HTML element(s)). Take a look at [this question](http://stackoverflow.com/questions/31588871/it-can-make-a-modal-popup-window-with-just-html-and-css).
    – nnnnnn Apr 30 '17 at 06:06
  • Possible duplicate of [How to edit a JavaScript alert box title?](http://stackoverflow.com/questions/1905289/how-to-edit-a-javascript-alert-box-title) – JJJ Apr 30 '17 at 06:09
  • No it is impossible to change Title you can just pass the message to `alert()`, but you can override `window.alert` to customize it as you want !!!. – Aria Apr 30 '17 at 06:20

1 Answers1

2

It is not possible with browser's native alert box. However you can always use JavaScript alert box.

  function showAlert(){
    $( "#dialog" ).dialog({modal: true});
}
  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">

<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

<body>
<input type="button" value="Alert" onClick='showAlert()'>
<div id="dialog" title="" style="display: none;">
  <p>Alert box. Lorem Ipsum.</p>
</div>
 
</body>
Hari Das
  • 10,145
  • 7
  • 62
  • 59
  • 3
    This assumes the user is wanting to use jQuery rather than just JavaScript. – kojow7 Apr 30 '17 at 06:42
  • ["Unless another tag for a framework/library is also included, a pure JavaScript answer is expected."](http://stackoverflow.com/tags/javascript/info) – nnnnnn May 01 '17 at 03:36