Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between window, window.top and window.parent?

I just noticed that top, window and parent variables are giving me the same value. I was testing this at gmail inbox page. Does anybody know what is the difference between these three values?

like image 612
alter Avatar asked Aug 13 '10 04:08

alter


People also ask

What is window parent?

The Window. parent property is a reference to the parent of the current window or subframe. If a window does not have a parent, its parent property is a reference to itself.

What does window top mean?

Description. An object. The topmost window in the hierarchy of windows in the current browser window.

What does window top location do?

Inside a frame, window refers to current frame's window while top refers to the outermost window that contains the frame(s). So: window. location.

What is window parent location?

It is a property of the object 'window'. It returns the location of the topmost window in the window hierarchy. If a window has no parent, top is a reference to itself (window === window.top)


1 Answers

If you are within a frame:

  • window refers to the current frame.
  • parent refers to the parent of the current frame.
  • top refers to the outermost frame.

If you're not within any frame, these will all just be a reference to the current window. If you're only within one level of frame, parent and top will both be a reference to the same thing.

like image 93
thomasrutter Avatar answered Sep 19 '22 01:09

thomasrutter