473,320 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

FAQ Topic - How do I find the size of the window/browser canvas area?

-----------------------------------------------------------------------
FAQ Topic - How do I find the size of the window/browser
canvas area?
-----------------------------------------------------------------------

While it is often asked about window size, what is more relevant is
the "canvas area" of the browser.

Where supported in NN: (>NN4.0)

var winWidth = window.innerWidth;
var winHeight = window.innerHeight;

Where supported in IE: (>IE4.0)

var winWidth = document.body.clientWidth;
var winHeight = document.body.clientHeight;

When using IE6 with in CSS1Compat mode (i.e. with a Formal DOCTYPE):

var winWidth = document.documentElement.clientWidth
var winHeight = document.documentElement.clientHeight

Combined:

var winWidth, winHeight, d=document;
if (typeof window.innerWidth!='undefined') {
winWidth = window.innerWidth;
winHeight = window.innerHeight;
} else {
if (d.documentElement &&
typeof d.documentElement.clientWidth!='undefined' &&
d.documentElement.clientWidth!=0) {
winWidth = d.documentElement.clientWidth
winHeight = d.documentElement.clientHeight
} else {
if (d.body &&
typeof d.body.clientWidth!='undefined') {
winWidth = d.body.clientWidth
winHeight = d.body.clientHeight
}
}
}

Note: The dimensions can not be determined accurately until after the
document has finished loading.

http://msdn.microsoft.com/workshop/a...lientWidth.asp

http://docs.sun.com/source/816-6408-...ow.htm#1202446

http://msdn.microsoft.com/workshop/a.../measuring.asp
===
Postings such as this are automatically sent once a day. Their
goal is to answer repeated questions, and to offer the content to
the community for continuous evaluation/improvement. The complete
comp.lang.javascript FAQ is at http://jibbering.com/faq/index.html.
The FAQ workers are a group of volunteers.

Feb 15 '07 #1
1 4037
FAQ server said the following on 2/14/2007 7:00 PM:
-----------------------------------------------------------------------
FAQ Topic - How do I find the size of the window/browser
canvas area?
-----------------------------------------------------------------------

While it is often asked about window size, what is more relevant is
the "canvas area" of the browser.

Where supported in NN: (>NN4.0)
Shouldn't that just say "Where supported:" since >NN4.0 is far from
being the only place innerWidth and innerHeight is supported? The way
this entry is written it implies, to me, that you can only find the
dimensions in >NN4.0 or >IE4.0, which leaves any other browser out of
the picture which is far from being accurate.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Feb 15 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Billy | last post by:
Hi, This is in connection to the tread: Re: changing browser text settings?? I am wondering if there is a way to retrieve the browsers text size (not change! ;-) ) so that I can dynamically...
0
by: syed_saqib_ali | last post by:
Below is a simple code snippet showing a Tkinter Window bearing a canvas and 2 connected scrollbars (Vertical & Horizontal). Works fine. When you shrink/resize the window the scrollbars adjust...
1
by: syed_saqib_ali | last post by:
Below is a simple code snippet showing a Tkinter Window bearing a canvas and 2 connected scrollbars (Vertical & Horizontal). Works fine. When you shrink/resize the window the scrollbars adjust...
9
by: Les Juby | last post by:
I understand that there are several ways to effectively control the browser delivery of HTML to make the most effective use of the different screen resolutions today. (And in the foreseeable...
17
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I find the size of a browser window?...
4
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I find the size of the window/browser canvas area?...
31
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I modify the current browser window?...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.