admin管理员组

文章数量:1397093

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?

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?

Share Improve this question asked Sep 2, 2009 at 15:49 Nathan LongNathan Long 126k104 gold badges351 silver badges464 bronze badges 1
  • (Yes, I'm aware that alert() is a terrible UI choice. I have a harmless prank in mind.) – Nathan Long Commented Sep 2, 2009 at 16:13
Add a ment  | 

2 Answers 2

Reset to default 4

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

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.

本文标签: Is it possible to create a noncentered Javascript alert boxStack Overflow