Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to create a non-centered Javascript alert box?

Tags:

javascript

For a standard Javascript alert() box, is it possible to have it appear in a position other than the center of the screen? Can you specify horizontal and/or vertical position?

like image 326
Nathan Long Avatar asked Apr 27 '26 04:04

Nathan Long


2 Answers

Afaik, it cannot be positioned where you want it.

Instead of using the default js alert box, you can always use one of the JS framework / toolkit solutions that offer way more in terms of functionality and customization.

I'm personally a fan of jQuery and jQueryUI

like image 67
code_burgar Avatar answered Apr 29 '26 17:04

code_burgar


Indeed, I would personally discourage you from using Javascript alert() boxes altogether - they look 1995-ish and don't provide for a nice, customizable user experience. Instead, like the other poster suggested, use a standard Javascript library that will allow you to pop up a "modal" floating DIV, as well as paint a semi-transparent color all over the background, which will make for a beautiful, understandable, easy-to-use user interface.

like image 23
Alex Weinstein Avatar answered Apr 29 '26 16:04

Alex Weinstein



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!