473,396 Members | 1,834 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,396 software developers and data experts.

Hi, can this be done? [determining size of specified browser window]

Is there anyway to determine the present pixel height & width size of a
open browser window? :)

Nov 2 '06 #1
19 2098
ca******@gmail.com said the following on 11/1/2006 8:47 PM:
Is there anyway to determine the present pixel height & width size of a
open browser window? :)
Yes.

Your first Hint is that it is covered in the FAQ.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 2 '06 #2
and the second is check out randy's signature .....

Nov 2 '06 #3
Thank you for that. The only example that partially works (IE >6.0,
XP) is:

<script>

var winWidth = document.documentElement.clientWidth
var winHeight = document.documentElement.clientHeight
alert(winWidth)
alert(winHeight)

</script>

The winHeight comes back as 0.... the other examples show undefined....
is there something I am parsing wrong here? :)

Nov 2 '06 #4
ca******@gmail.com said the following on 11/2/2006 3:18 PM:
Thank you for that. The only example that partially works (IE >6.0,
XP) is:

<script>

var winWidth = document.documentElement.clientWidth
var winHeight = document.documentElement.clientHeight
alert(winWidth)
alert(winHeight)

</script>

The winHeight comes back as 0.... the other examples show undefined....
is there something I am parsing wrong here? :)
Yes.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 2 '06 #5
Can you please provide a working solution? Thank you!

Nov 2 '06 #6
Hmm, ok, then it appears your FAQ has unworking examples. What is the
working solution you don't mind sharing with the group? Thank you.
Best regards, Kat

Nov 2 '06 #7
ca******@gmail.com said the following on 11/2/2006 5:50 PM:
Hmm, ok, then it appears your FAQ has unworking examples.
It does? Where? The code in the FAQ does precisely what the FAQ says it
will do.
What is the working solution you don't mind sharing with the group?
"Working solution" to what?

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 2 '06 #8

I'm very sorry Randy - If I take your words at face-value you are
saying in my earlier message that "Yes." I am parsing something
wrong?.... the code I presented in my prior message was a cut-and-paste
from your FAQ. I get the width demension but not the height, which
comes back as 0. The other examples don't work at all.... in Firefox
or IE 6.0 & 7.0. I might be overlooking something. When you say Yes,
can you articlate my misunderstanding? :)

Nov 3 '06 #9
TC

ca******@gmail.com wrote:
I'm very sorry Randy -
He's not interested in helping you. Perhaps you did not genefluct
correctly.

Try here:
http://msdn.microsoft.com/library/de.../measuring.asp

Remember the 'type' attribute in your <scriptelements:
<script type="text/javascript">

HTH,
TC (MVP MSAccess)
http://tc2.atspace.com

Nov 3 '06 #10

ca******@gmail.com wrote:
I'm very sorry Randy - If I take your words at face-value you are
saying in my earlier message that "Yes." I am parsing something
wrong?.... the code I presented in my prior message was a cut-and-paste
from your FAQ.
The problem isn't the code, it's when you call it. Wrap it in a
function and call it onload, then it will "work" in IE too:

function foo(){
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;
}
alert('winWidth: ' + winWidth
+ '\nwinHeight: ' + winHeight);
}

window.onload = foo;

--
Rob

Nov 3 '06 #11
super-hawaii-, i see top quality job at microsoft msdn department in
your future :)
RobG wrote:
ca******@gmail.com wrote:
I'm very sorry Randy - If I take your words at face-value you are
saying in my earlier message that "Yes." I am parsing something
wrong?.... the code I presented in my prior message was a cut-and-paste
from your FAQ.

The problem isn't the code, it's when you call it. Wrap it in a
function and call it onload, then it will "work" in IE too:

function foo(){
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;
}
alert('winWidth: ' + winWidth
+ '\nwinHeight: ' + winHeight);
}

window.onload = foo;

--
Rob
Nov 3 '06 #12

ca******@gmail.com wrote:
Thank you for that. The only example that partially works (IE >6.0,
XP) is:

<script>

var winWidth = document.documentElement.clientWidth
var winHeight = document.documentElement.clientHeight
alert(winWidth)
alert(winHeight)

</script>

The winHeight comes back as 0.... the other examples show undefined....
is there something I am parsing wrong here? :)
Kat, tha problem may be in CSS. If you using standards-compilant mode
then you might set height of the page to 100%
<style type='text/css'>
HTML,BODY {height:100%}
</style>

Val Polyakh,
http://trickyscripter.com

Nov 3 '06 #13
TC said the following on 11/3/2006 12:35 AM:
ca******@gmail.com wrote:
>I'm very sorry Randy -

He's not interested in helping you.
I helped in more ways than one. The fact that neither of you realize
that says something in and of itself.
Perhaps you did not genefluct correctly.
Sesquipedalian behavior is a sign of ignorance, not intelligence.
Try here:
http://msdn.microsoft.com/library/de.../measuring.asp
Yeah, that shows how to get the dimensions of the browser window - it
doesn't. Yet the reference I referred them to (in this groups FAQ) does
precisely what was asked for. Who is it that isn't helping?
Remember the 'type' attribute in your <scriptelements:
<script type="text/javascript">
And then remember that it's irrelevant to the question? The DTD makes
more difference than the type attribute ever will.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 3 '06 #14
Randy Webb schreef:
TC said the following on 11/3/2006 12:35 AM:
>ca******@gmail.com wrote:
>>I'm very sorry Randy -

He's not interested in helping you.

I helped in more ways than one. The fact that neither of you realize
that says something in and of itself.
>Perhaps you did not genefluct correctly.

Sesquipedalian behavior is a sign of ignorance, not intelligence.
>Try here:
http://msdn.microsoft.com/library/de.../measuring.asp

Yeah, that shows how to get the dimensions of the browser window - it
doesn't. Yet the reference I referred them to (in this groups FAQ) does
precisely what was asked for. Who is it that isn't helping?
>Remember the 'type' attribute in your <scriptelements:
<script type="text/javascript">

And then remember that it's irrelevant to the question? The DTD makes
more difference than the type attribute ever will.
http://whatsmy.browsersize.com/
Nov 4 '06 #15
ar*********@nietbereikbaar.nl said the following on 11/4/2006 1:31 PM:
Randy Webb schreef:
>TC said the following on 11/3/2006 12:35 AM:
>>ca******@gmail.com wrote:
I'm very sorry Randy -

He's not interested in helping you.
<snip>
http://whatsmy.browsersize.com/
All that does is prompt me to install some Java Applet that I don't care
to install.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 4 '06 #16
VK
ca******@gmail.com wrote:
Is there anyway to determine the present pixel height & width size of a
open browser window? :)
No (with the default security settings). This "No" is relevant to the
literal interpretation of your question: "can I find out pixel size of
application window I'm seeing on my monitor".

The <http://jibbering.com/faq/#FAQ4_9(which what you seem used) is
irrelvant to your question as interpreted above.

<FAQENTRY>
http://jibbering.com/faq/#FAQ4_9 is called "How do I find the size of a
browser window?" while it is about of determining the working area of a
document open in a browser window.
</FAQENTRY>

Unless it's a specially made newcomer's trap for dansing around the
caught victimes (like Mr.Webb just demonstrated) - unless that the FAQ
title has to be re-phrased to something more corresponding to its topic.

Nov 5 '06 #17
"RobG" <rg***@iinet.net.auwrites:
The problem isn't the code, it's when you call it. Wrap it in a
function and call it onload, then it will "work" in IE too:
[...]
And now for a bonus points: Is there way to know the DPI of the screen
in which the user agent runs?

I found this :

----------snip-----------
By the way there is already a simple way to detect DPI in JavaScript,
provided that the OS and browser implement them right: Create a div
with width=height=1in, then query it¡Çs pixel size
(offsetWidth/offsetHeight). That is the real ¡Èdots per inch¡É, and I
am sorry if the browser feel the need to mess that up.
---------/snip-----------

at the following address: http://webkit.org/blog/?p=55 (in one of the comments)

...but is there any other way?

Thank you,
Arnaud
function foo(){
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;
}
alert('winWidth: ' + winWidth
+ '\nwinHeight: ' + winHeight);
}

window.onload = foo;

--
Rob
--
Arnaud DIEDEREN
Software Developer
IONIC Software
Rue de Wallonie, 18 - 4460 Grace-Hollogne - Belgium
Tel: +32.4.3640364 - Fax: +32.4.2534737
mailto:ad@ionicsoft.com
http://www.ionicsoft.com
Nov 7 '06 #18
Arnaud Diederen (aundro) said the following on 11/7/2006 7:58 AM:
"RobG" <rg***@iinet.net.auwrites:
>The problem isn't the code, it's when you call it. Wrap it in a
function and call it onload, then it will "work" in IE too:
[...]

And now for a bonus points: Is there way to know the DPI of the screen
in which the user agent runs?
You ask a question and then give an answer?
I found this :

----------snip-----------
By the way there is already a simple way to detect DPI in JavaScript,
provided that the OS and browser implement them right: Create a div
with width=height=1in, then query it’s pixel size
(offsetWidth/offsetHeight). That is the real “dots per inch”, and I
am sorry if the browser feel the need to mess that up.
"mess that up" in what way?

A better question is "Why does the DPI matter in a WWW context?"

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 7 '06 #19

Hi,

Randy Webb <Hi************@aol.comwrites:
You ask a question and then give an answer?
I give _one possible_ answer, but I don't know if that's really
reliable and/or whether there are any other answers :)
>
>I found this :

----------snip-----------
By the way there is already a simple way to detect DPI in JavaScript,
provided that the OS and browser implement them right: Create a div
with width=height=1in, then query it's pixel size
(offsetWidth/offsetHeight). That is the real 'dots per inch', and I
am sorry if the browser feel the need to mess that up.

"mess that up" in what way?
Since that quoted text is part of the 'solution' I found (in the
comments at http://webkit.org/blog/?p=55) and therefore I didn't write
it, I can only presume he/she meant that the browser might not
properly implement the CSS 'inch-based' rules computations.

>
A better question is "Why does the DPI matter in a WWW context?"
Because I'm into GIS (Geographic Information Systems) web
applications, and in order to give the user a relevant 'scale' of,
say, a 800x600 map/image, it would be appropriate to know the size (in
inches) of that map/image. So far, I can only approximate a scale,
using a fixed DPI.

Arnaud.

>
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
--
Arnaud DIEDEREN
Software Developer
IONIC Software
Rue de Wallonie, 18 - 4460 Grace-Hollogne - Belgium
Tel: +32.4.3640364 - Fax: +32.4.2534737
mailto:ad@ionicsoft.com
http://www.ionicsoft.com
Nov 10 '06 #20

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

Similar topics

8
by: Johnny Knoxville | last post by:
I've added a favicon to my site (http://lazyape.filetap.com/) which works fine if you add the site to favourites the normal way, but I have some JavaScript code on a couple of pages with a link,...
2
by: Jan Roland Eriksson | last post by:
Archive-name: www/stylesheets/authoring-faq Posting-Frequency: twice a week (Mondays and Thursdays) Last-modified: August 28, 2002 Version: 1.15 URL: http://css.nu/faq/ciwas-aFAQ.html...
0
by: Jan Roland Eriksson | last post by:
Archive-name: www/stylesheets/authoring-faq Posting-Frequency: twice a week (Mondays and Thursdays) Last-modified: April 10, 2003 Version: 1.16 URL: http://css.nu/faq/ciwas-aFAQ.html Maintainer:...
3
by: w2000 | last post by:
Greeting all, I am studying Javascript to custom my yahoo estore, I need to open a custom sized window in a new browser , I tried the following script on 3 different PCs running XP pro. IE 6,...
1
by: Doug | last post by:
When opening a DOC file via a hyperlink, is it possible to force Microsoft Word to open in a specified-size window? For example, a 600x300 window? I realize that MS Word will 'remember' the...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
7
by: Tim Rogers | last post by:
Hi folks, this is a resolution-detect script that I used on a site. As you can see it is designed to detect when the screen resolution falls below a certain level then load an alternative style...
3
by: Steve Sobol | last post by:
I need to use JavaScript and the DOM to determine the available amount of browser space - the total size of the browser window minus whatever space is used by chrome. window.innerHeight and...
4
by: Ty | last post by:
Hello all, I am creating a web site with Visual Stuido 2008. I am trying to use a java script file to create a busybox for login from this page http://blogs.crsw.com/mark/articles/642.aspx. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.