JavaScript Tip of the Week for August 26, 1996: What's New in 3.0 | 4

for August 26, 1996: What's New in Windows

The basic opening of the window is the same as in 2.0. But the controls that you can have over the window have been greatly increased. The function below simply opens a window with name "TheWindow" and a reference variable "NewWindow". The reference variable will be used later on.

Please press this button to initiate the window code:
One of the new features in 3.0 is being able to put the window in focus. This means on most systems that it will bring the window in front of all other windows.
This is done using the focus command:

NewWindow.focus()

"NewWindow" is the name of the window's reference variable. Put that together with focus and you get a great new tool. Another feature of the window is being able to "blur" it. On most systems this will bring it out of focus, and therefore send the window behind the main window. Put the window in focus again and then press (in the window) the Put Window in Blur button to see the effect.
This is done using the blur command:

NewWindow.blur()

The window's code uses self.blur() to blur itself. Using these two methods together with another event handler, I've created a little JavaScript goody; It's window that always stays on top. Though not a true always-on-top window, it is a relatively good approximation with a few bugs of its own. This could be very useful for remotes and other floating toolbar type windows. It could also be very annoying if not used properly. The code to for this type of window is very simple, just put these two functions in the window, which will allow "always on top" to be toggled on and off:

Then add a button, or any other object, that runs the function ChangeOnTop() whenever it is pressed. This is the button that will toggle the window's "always on top" property. Try this method out by pressing the button below:
In this case, changing the time variable in setTimeOut function will greatly change the way the window works. If you set the time to one millisecond the window will never leave your sight. If you set the time to one second, the window will disappear for one second everytime it gets out of focus (behind other windows).

Another new feature is the ability to automaticallty scroll windows. This is done using the x and y coordinates of the window. Try this method out:
This is done using the scroll function:

NewWindow.scroll(x-coordinate,y-coordinate)

Negative integers will cause the page to scroll down and posative integers will scroll up.

One last thing; when refering to the properties of a window opened by another frame, such as the focus, the syntax should look like this:

parent.frame_name.window_reference_variable.focus()

Well, that's about it for new windows features, if I missed any important ones that you know about then mail me and I'll include them in this tip.