On an html page, how can I align the 'warning' lin开发者_Python百科e in the below confirm call, to appear in the middle of the pop-up window?
confirm('You are about to delete 5 rows. \nWARNING: Strawberry cakes won\'t be effected!');
You can't. The confirm()
window style (including dimensions) can vary between browsers and operating systems and you can't be sure of the font used either.
You might be better off using something like jQueryUI to create a seemingly modal dialog window to replace confirm()
with something that looks better and integrates more with the look and feel of your site. (Demo here).
No - the way how the confirm is rendered is up to the browser.
Because the browser usually doesn't use a monospaced font, you can't reliably work with spaces, either.
You'll have to live with this or use a custom confirm()
instead.
you mean centering the confirm message ? You can't, unless you write your own "confirm" function (make a DIV layer popup & decorate it nice with CSS)
Also, your code has errors. You have to escape single quotes.
Confirm method generates system dialog by the browser. So you can't be completely sure how your message will look like.
To get the maximum control on the visual of the dialogs you create try to use some widget library, jQuery UI for example. It has dialog widget which can be customized in many ways. Here is the demo of the modal confirmation dialog.
Possible to do, you can do this. confirm(msg1 + "\n" + msg2 + "\n" + msg3);
Refer here: http://geekswithblogs.net/dotNETvinz/archive/2009/08/03/adding-line-breaks-in-javascript-alert-and-confirm-popup-message.aspx
精彩评论