Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
263 views
in Technique[技术] by (71.8m points)

javascript - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.9k users

...