Window Object
This page shows the use of JavaScript with the "window" object.
Most of the JavaScript has been tested with IE 5.1 (sometimes Netscape 4.61).
(Warning: If using Netscape,
when you close this browser window you will be asked to Grant permission to
JavaScript modify the browser. If you say yes, the program will restore
the original browser window settings prior to loading the web page.)
Click here to go to a
page where you can download these examples (see Browse Window section)
Browser Window - Simple,
not to techy, examples of opening and closing windows. Some of the windows
do not have toolbars.
Window Properties
Resizing the Browser Window (IE & NS)
- Note: I moved your browser window to the very top cooridinate once the page was loaded
in the function: init(). In that same function I could have resized the window (code
is commented). My saving the originals windows properties and restoring on an I also
store your original settings.
- Click Here - to run JavaScript
that will resize the window to 640 x 480.
- Click Here - to run JavaScript
that will resize the window to 300 x 480.
Window's Chrome Properties
Chrome Items
- window.menubar.visible - (File, Edit, View, etc...)
- window.toolbar.visible - (Back, Forward, Reload/Refresh, etc...)
- window.locationbar.visible - (URL/Location, etc...)
- window.personalbar.visible - (Custom bar - What's New?, What's Cool?, etc...)
- window.scrollbars.visible - (IE & NN - Right scrollbar, NN - Bottom scrollbar)
- window.statusbar.visible - (the status bar at the bottom of the browser)
Changing the current Window Chrome Items Properties
WARNING - This section only works with
Netscape. The JavaScript reference book says that these properties are compatibly
with IE3 and greater but testing with IE5.1 did not work for me.
JavaScript
To change any of the chrome items Java needs to be enabled in the users
browser settings and a call to netscape.security to enable
"UniversalBrowserWrite" must be made. This generally means that the user
may have to "Grant" privilege to perform this function. Also, you may
experience a delay as the Java security applet loads.
- WARNING - before clicking on these links, read the information directly above this
statement.
- Click Here - Change Window chrome
items (locationbar, menubar, personalbar, scrollbars,statusbar, toolbar).
- Click Here -
Restore Window chrome items (locationbar, menubar, personalbar, scrollbars,statusbar,
toolbar).
Creating a New Window
- Click Here - Create a new window with no
bar's & fill window with content via JavaScript.
- Example of creating a new windows with
a name using the open() function.
- Benefits/Disadvantages:
- A new window is created only if the window by that name does not
exist. If a window by that name does exist it will replace its
content.
- When the window already
exists, the content is change, however the window is not brought to the
front. I don't think it is possible to bring the window to the
front. This maybe confusing to the user.
- Once the window is created, the open() function will not
change the size of the window.
- Examples
- Example of creating a new windows without
names using the open() function.
- Benefits/Disadvantages:
- A new window is always created.
- Since a new window is always created the user will have to
continually close the windows.
- The new window is always brought to the front.
- Examples
- name=""
NoName -
(100x200) load with URL ex_window_name_test3A.htm.
- name=""
NoName -
(100x400) load with URL ex_window_name_test3B.htm.
- ex_windowlast.htm - JavaScript that
experiments with loading a web application which in turn creates a new
browse window so that the new window will be the default window used
to load a URL if one is loaded from a windows application - not your
web application!. This is not a good solution. Remember that
some windows applications will load URL's into the last browser window that
was launched.
Miscellaneous Window Functions
- ex_windowname_winA.htm
- JavaScript that gives a name to a window and then resets the name when the
window is closed. (Later I plan to show how to access the windows via
the name).
- Click Here - Example of catching
window events at the "window" level (onClick, onMouseDown, etc...).
- Click Here - Example of
disabling the right mouse button.
- Click Here
-Example of disabling the right mouse button & removing window
bars which will remove the option for the user to "view source"
unless they go directly to the html file.
- Click Here - Examples of hiding
JavaScript and the HTML source code from the user.
- No example yet - just a note:
The following example will call a JavaScript function when you click on the
link. The user sees "javascript:void(0)" in the status bar
if he moves his mouse over the link. This way you can also play with
onMouseover, onMouseout, etc...
<a href="javascript:void(0)" onClick="fOpenBrWindow('to0103c_hs1.htm','','width=410,height=310')">system,</a>