开发者

Javascript remove warning symbol in popup

开发者 https://www.devze.com 2023-03-23 05:40 出处:网络
If I use alert, the warning symbol will be pr开发者_如何转开发esent in the popup as given below. Is it possible to display a popup without warning symbol in javascript?

If I use alert, the warning symbol will be pr开发者_如何转开发esent in the popup as given below. Is it possible to display a popup without warning symbol in javascript?

Javascript remove warning symbol in popup


It is not possible to change anything about the built-in alert() and confirm() popups except for the text of the message - this is a browser security feature.

You can simulate a popup dialog by building one from HTML using a transparent <div> to cover the rest of your page so that users can't interact with the rest of the page until the dialog closes. (Or use a translucent <div> to make it more obvious to the user that the rest of the page is "disabled".)

I would not bother coding this from scratch when there are lots of JS libraries that do it for you. The jQuery dialog is pretty easy to use, to name just one option.


You cannot change/replace the icon. Actually, in Chrome icon is not displayed.
I would suggest using jQuery UI. Check out this link


I replaced all my alert() with jQuery UI dialog (+1 to Igor)

If anyone wants to do it easily, here is what I did:

Simply include jQuery UI, eg.

<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link type="text/css" rel="Stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />

and create this JavaScript function

function AlertUi(title, message) {
  if (!(/<\/?[a-z]{1,3} ?\/?>/.test(message))) // Probably not HTML (edit this line as you wish)
    message = message.replace(/\n/g, '<br/>'); // Replace \n with <br/>

  $("<div title='" + title + "'>" + message + "</div>").dialog(); // Show the popup
}

Then you could do a Replace All using any text editor, replacing alert( with AlertUi('',, eg.

alert('Hello');

becomes

AlertUi('', 'Hello');


I suggest you using cool dialog modal, called colorbox, Its awesome at least for me.


I would just use a pop-up instead of an alert. Then you can set it to whatever size you want with whatever you want in it.

function newPopup(url) {

    params = 'width=whatever';
    params += 'height=whatever';
newwindow = window.open(url, 'name', params);
    if (window.focus) { newwindow.focus() }
    return false;
}

Then just build your popup window and call it in an onClick() function.

0

精彩评论

暂无评论...
验证码 换一张
取 消