Question: How can I create pop-up dialog boxes without using the
confirmmethods are useful for displaying message boxes, the words and decorations that come with these message boxes are often inappropriate or cause the user unnecessary alarm.
For example, suppose that we want to extend a personal gesture of thanks to a user for visiting one of our web pages. We think it would be fun if a pop-up box displayed the words, "Thanks for visiting our web site." To accomplish this, we might use the
alert method, as follows:
The other methods have drawbacks, too. For example, the confirm method is also confusing because "OK" and "Cancel" buttons are displayed with the message, and the user will wonder which one to push.
promptmethod is even worse; not only does it have the same two buttons, but it also has an input field.
This is clearly not appropriate for a simple greeting box. We are only trying to greet the user, not solicit input, so the input field will confuse the user.
open method, a method of the
open method allows programmers to control window properties such as size, scroll bars, and even the presence or absence of menu and tool bars. Opening a small pop-up window to display another document or image is easy, as the code below demonstrates:
The first parameter in the
window . open ('welcome.html', '', 'width=400,height=200');
The source code for welcome.html might appear as follows:
window . close method is called to close the pop-up window.
November 28, 1996