I have just observed that every page has length
global variable.
What does this variable represent? Is it somehow related to how many iframes/frames are loaded on page?
It'd be happy if a doc reference is provided.
For example, on Chrome new tab page its value is 17
and here, on StackOverflow it is 0
.
I have just observed that every page has length
global variable.
What does this variable represent? Is it somehow related to how many iframes/frames are loaded on page?
It'd be happy if a doc reference is provided.
For example, on Chrome new tab page its value is 17
and here, on StackOverflow it is 0
.
- 3 Sure! I don't think it's that difficult to type "window.length" into a search engine. Since it takes all of about twenty seconds to find the answer if you actually bother, that seems like it fits the criteria for "lacks research effort". – Anthony Grist Commented Oct 27, 2014 at 15:34
- 1 @IonicăBizău Downvote as, per the downvote mouseover, "this question does not show any research effort". – admdrew Commented Oct 27, 2014 at 15:35
- 2 @AnthonyGrist But form other hand, the question itself is really good. For example I didn't know that. Now I know, hence OP deserves upvotes. not downvotes. I'm sure many people can learn something from even simplest questions like this one. – dfsq Commented Oct 27, 2014 at 15:35
- 1 @dfsq, this site is really not intended to answer basic things like this. It specifically allows for downvoting any question that shows no effort in research. We value effort from the person asking the question, rather than them sitting back and saying "feed me." – Jonathan M Commented Oct 27, 2014 at 15:37
- 4 I don't think I would have ever googled window.length if it wasn't for this question, questions that lack research effort are frowned upon but given the op's rep and github track it seems more of a "here's something interesting" question. – Patsy Issa Commented Oct 27, 2014 at 15:47
2 Answers
Reset to default 15Yes, it's how many frames (including iframes) are in the current window:
https://developer.mozilla/en-US/docs/Web/API/Window.length
W3 specification:
http://www.w3/html/wg/drafts/html/master/browsers.html#accessing-other-browsing-contexts
window.length
Returns the number of frames (either
frame
oriframe
elements) in the window.
Example
if (window.length) {
// this is a document with subframes
}
MDN Reference
Note: No part of this answer es from me. It all es from the referred source.