A Console Cookbook – Part 2
“One of the benefits of using JavaScript to open a new window is that you are able to specify the window’s properties”“One of the benefits of using JavaScript to open a new window is that you are able to specify the window’s properties”
After the first installment of A Console Cookbook, I received a lot of email from newbies wanting to know more about specifying window properties, a process which I will explore below:
One of the benefits of using JavaScript to open a new window is that you are able to specify that window’s “properties.” You can learn a lot more about window properties from this tutorial, but for our purposes, window properties may be easily defined. For an example of relevant syntax, study the following event code:
window.open
(‘http://www.yoursite.com’, ‘_blank’,
‘resizable=no,scrollbars=no,
toolbar=no,location=no,
directories=no,status=no,
menubar=no’);
Note that while these statements appear on multiple lines for clarity, to be properly executed, they must appear as one continuous line of code. All of the defined parameters are quite self-explanatory:
First,
window.open is the command to (obviously) open a new [document] window. The location of the new document is given, followed by the name of the window you wish to load this document into. This will usually be ‘_blank’ to reference a new window. (Back Button Redirects are one exception, specifying ‘_self’ in order to load the document into the current window. When doing this, you cannot specify other attributes; your window retains its original configuration.)
Next follows the actual window properties. Specify either “yes” or “no” to make your selections. Setting everything to “no” makes for a typical “console window,” but you may for instance wish to activate the status bar in order to show hyperlink OnMouseOver info.
Two additional parameters are height=XXX and width=XXX, with “XXX” being replaced by the desired value in pixels. These are useful if you know the actual dimensions of your document. This is not always as easy as it seems (unless you are using a set graphic size for a console), and can result in only a partial view of a document in a window without scrollbars!
The best way for you to see how changing these options affects the appearance and functionality of your console is through experimentation. Set up a simple console page, and see how adding the toolbar or status bar, etc. changes things! Test your code across as many browsers as possible, and find something that works for you.
In my next installment, I’ll show you how to pop multiple windows and how to set up a back button re-direct, plus provide a few hints on maximizing console effectiveness…
Reader Comments on this Article:
Comment by:Summary:
StephenMore Code!
Shiprekdone of the best pull consoles…
MultimanConsole Sequence