最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - What is the global length variable (window.length)? - Stack Overflow

programmeradmin4浏览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.

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.

Share Improve this question edited Oct 27, 2014 at 15:42 Hanky Panky 46.9k9 gold badges75 silver badges95 bronze badges asked Oct 27, 2014 at 15:29 Ionică BizăuIonică Bizău 113k93 gold badges307 silver badges487 bronze badges 8
  • 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
 |  Show 3 more ments

2 Answers 2

Reset to default 15

Yes, 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 or iframe 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.

发布评论

评论列表(0)

  1. 暂无评论