The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Web Design
> HTML Programming
|
How to obtain the current browser resolution
Discuss How to obtain the current browser resolution in the HTML Programming forum on Dev Shed. How to obtain the current browser resolution HTML Programming forum covering discussions of HTML and XHTML, as well as HTML-related issues such as writing W3C Compliant code. Use HyperText Markup Language for building websites.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

June 24th, 1999, 12:32 PM
|
|
Guest
|
|
Posts: n/a
Time spent in forums:
Reputation Power:
|
|
|
Hi,
Can someone tell me how to obtain the resolution of the client browser in javascript. I don't found this in the navigator object.
Regards
|

June 29th, 1999, 09:55 AM
|
|
Guest
|
|
Posts: n/a
Time spent in forums:
Reputation Power:
|
|
|
Hi Phil,
You might be a little confused here - of course, I might be a little confused too?
The term 'Resolution' describes a monitor setting of the user's computer. It's not a browser setting and I don't think you can access that info. from JS or from the web browser.
------------------
Matthew J. Flynn
http://webcoder.net
|

July 5th, 1999, 11:59 PM
|
|
Guest
|
|
Posts: n/a
Time spent in forums:
Reputation Power:
|
|
|
You can get the current Resoultion through JS
Here is how to do it
<SCRIPT LANGUAGE=javascript>var xy = navigator.appVersion;xz = xy.substring(0,4);document.write('<B> ',screen.width,' x ',screen.height,'</B>')</SCRIPT>
This will write it to the document.
------------------
L8Rz
WhiteKnight
|

July 7th, 1999, 11:21 AM
|
|
Guest
|
|
Posts: n/a
Time spent in forums:
Reputation Power:
|
|
|
Here is the same thing, but it notifies the client if the resolution does not match the anticipated design resolution.
<head>
</script>
<script language="JavaScript1.2">
var winX = screen.width;
var winY = screen.height;
if (winX <= '640') {
newWindow = window.open('reswarning.htm', '', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars="no",width=300,height=225');
}
</script>
</head>
In the reswarning.htm (pop-up window) file, you can also insert this piece of JavaScript code for additional enhancement.
<script language="JavaScript1.2">
var winX = screen.width;
var winY = screen.height;
document.write('Your screen resolution is ' + winX + ' x ' + winY + ', which is below the recommended size for this application. If possible, please reset your screen resolution to 800 x 600 or higher. Thank you!');
</script>
--Good Luck
------------------
Striker
|

November 7th, 2012, 12:58 PM
|
|
Contributing User
|
|
Join Date: Nov 2008
Posts: 68

Time spent in forums: 12 h 49 m
Reputation Power: 5
|
|
The other replies are incorrect, the code they gave you will give you the screen resolution, not the browser width.
See the website:
http://www.w3schools.com/jsref/prop_win_innerheight.asp
Syntax
Get:
window.innerWidth
window.innerHeight
Set:
window.innerWidth=pixels
window.innerHeight=pixels
|

November 7th, 2012, 02:14 PM
|
 |
CSS & JS/DOM Adept
|
|
Join Date: Jul 2004
Location: USA
|
|
This thread is also over 12 years old. Next time please check the last post date when you reply to a thread that you found from a search query.
Please do not post links to that site here. There are better resources elsewhere. I recommend you read this: W3Fools: A W3Schools Intervention
|

November 7th, 2012, 02:53 PM
|
|
Contributing User
|
|
Join Date: Nov 2008
Posts: 68

Time spent in forums: 12 h 49 m
Reputation Power: 5
|
|
|
Sorry I know the posts were old, I was just hoping to help future searchers who come upon this topic like I did. W3schools was not even the first site I found the info on... but I closed out the original site and couldn't find it again, then when I searched W3 was the first one I found that had the same info.
The info on there is correct... it works anyway.
I see other help sites listed on the page about W3... I'll check them out.
Last edited by wakerunner : November 7th, 2012 at 02:59 PM.
|

November 7th, 2012, 03:34 PM
|
 |
CSS & JS/DOM Adept
|
|
Join Date: Jul 2004
Location: USA
|
|
It's good to make sure correct information is posted, but there is so much information available on the web (and on these forums) that is now outdated or just plain incorrect from the beginning, that correcting things that are obviously old like this is often more trouble than it's worth.
Don't let the "W3" in the name confuse you! W3C and W3Schools are two completely separate organizations. "W3" is simply another way to write "WWW", which is short for "world wide web".
I'm not aware of a one-stop-shop like W3Schools, but there are many better references for individual (or smaller groups of) languages elsewhere.
For JavaScript and DOM, I mainly use MDN (Mozilla Developer Network) and MSDN (Microsoft Developer Network):
https://developer.mozilla.org/en-US/docs/JavaScript
https://developer.mozilla.org/en-US/docs/DOM
MSDN HTML and DHTML Reference
JScript (ECMAScript3)
For CSS, I mainly use the official specs (I'm not going to list all of the CSS3 modules, if you need help finding one, just ask) and SitePoint's CSS Reference:
http://www.w3.org/TR/CSS21/
http://www.w3.org/TR/css3-selectors/
http://www.w3.org/TR/css3-background/
http://www.w3.org/TR/css3-box/
http://www.w3.org/TR/css3-ui/
http://reference.sitepoint.com/css
For HTML (and XHTML), I use the official specs but SitePoint's HTML Reference is good too:
http://www.w3.org/TR/html401/
Working Draft of the HTML5 specifications
http://www.w3.org/TR/xhtml1/
http://reference.sitepoint.com/html
For PHP, I use the official manual: http://php.net/manual/en/
For MySQL, I generally use the official documentation: http://dev.mysql.com/doc/
|

November 7th, 2012, 04:27 PM
|
|
Contributing User
|
|
Join Date: Nov 2008
Posts: 68

Time spent in forums: 12 h 49 m
Reputation Power: 5
|
|
|
Great! Thanks for all the info!
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|