The JavaScript Diaries: Part 7

By Lee Underwood


Building the Right Environment to Support AI, Machine Learning and Deep Learning


This property is used with frames. It refers to the frameset of the window or frame which contains the current frame. We'll look at this in more detail later when we learn about frames.


This property is just another way of referring to the current window object. Either of the following would be correct:



Using the self property instead of the window property makes it easier to read the code as it's clear which window is being referred to in the script.


This property holds the value of the text in the status bar of the browser window. It's related to the defaultStatus property above. This property, however, only changes the status line until something else changes it or it returns to the default state. It can be used to give detailed information about the link the mouse is hovering over. As with defaultStatus property above, be aware that many users prefer to see the URL rather than a message in the status bar.

An example of its usage would be (all on one line):

<a href="index.html" onMouseOver="window.status='Return home';
  onMouseOut="window.status='';" return true;">Home</a>

In the link above, the portion return true; causes the browser to display the onMouseOver event instead of the link itself, which is what the browser does by default. The onMouseOut sets the status to an empty string, allowing it to return to the default status when the mouse is moved away from the link. This is not required in Internet Explorer but is necessary in Mozilla-based browsers (Netscape and Firefox). (We will look at events, e.g., onMouseOver, in a later session.)


This property is used with frames. It refers to the topmost window in the frameset. We'll look at this in more detail later when we learn about frames.

There is an interesting, simple script using the top property that can help prevent your site from appearing within someone's frames on their Web site. Many people design their site with a top frame and then load Web pages from other sites in the bottom frame. That way the visitor won't leave the original site. They also don't directly visit your Web site. To break out of these types of frames, place the script below in the <head> section of your Web pages.

if (top != self) {
  top.location = self.location;

Let's take a look at what's going on here. Remember, the self property is just another way of referring to the current window object. Here we have a basic if statement. It says that if the topmost window in the frameset is not equal to ( != ) the current window object, then make the location of the topmost window equal to the current window object. In other words, if this page is in a frame, remove the current page and place it in the current window, without a frame.


This property refers to the current window object. It's actually a synonym for the self property.


That about covers the commonly used window objects. In our next session we will take a detailed look at the methods and event handlers associated with the window object and see how they work together with the window objects.

This article originally appeared on WebReference.com.

Page 4 of 4

Previous Page
1 2 3 4

Make a Comment

Loading Comments...

  • Web Development Newsletter Signup

    Invalid email
    You have successfuly registered to our newsletter.

    By submitting your information, you agree that htmlgoodies.com may send you HTMLGOODIES offers via email, phone and text message, as well as email offers about other products and services that HTMLGOODIES believes may be of interest to you. HTMLGOODIES will process your information in accordance with the Quinstreet Privacy Policy.

Thanks for your registration, follow us on our social networks to keep up-to-date