Setting the Features of Web Page Dialog Boxes
(Page 1 of 4 )
In this second part of a five-part series on producing web page dialog boxes, you'll learn how to set the text in the status bar of a window, control the size and position of a dialog box, and more. We'll also touch on the content of the dialog box, and how to make it carry out specific tasks when it closes.
Setting the Text in the Status Bar of a Window
Here I want to show you how to set the text in the status bar of the dialog box. The status bar can only take a string. If the window of the following code is opened, a dialog box (window) will be open immediately after because of the onload event. The status bar will display the phrase, “This is text for the status bar.”
<html>
<head>
<script type="text/javascript">
function openWindow()
{
myWindow = window.open("","","menubar=no,toolbar=no,status=yes","");
myWindow.status = "This is text for the status bar.";
}
</script>
</head>
<body onload="openWindow()">
<!-- the body elements of the main window go here -->
</body>
</html>
The statement window.open() returns a reference to the new window (dialog box) it has opened. If you need this reference, you can assign an identifier to it as follows:
myWindow = window.open();
Here the word "window" (without quotes in the code) is the object of the current window (web page), while myWindow is the reference of the newly opened window, returned by the statement “window.open().”
If you do not need the reference, simply do not assign it to an identifier, as follows:
window.open()
Do not forget that the open() method takes arguments.
To have text in the newly opened window, type the following into the parent window:
myWindow.status = "This is text for the status bar.";
Here, status is an attribute, which takes a string as a value. The above statement is typed in the parent window to take effect in the child (opened) window. The equivalent statement to be typed into the child window is:
window.status = "This is text for the status bar.";
Remember, that window is the object of the current web page (which has the statement).
As I said in the previous part, for simplicity, we shall not use the status bar in this series.
Next: Size and Position >>
More HTML Articles
More By Chrysanthus Forcha