473,480 Members | 4,841 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Monitor resolution

How to get monitor resolution using javascript?
Jul 23 '05 #1
3 2640
*Mario* wrote:
How to get monitor resolution using javascript?


var strDPI = prompt("What is D.P.I. of your display?");
alert(strDPI);
--
Andrew Urquhart
- FAQ: www.jibbering.com/faq/
- Archive: www.google.com/groups?q=comp.lang.javascript
- Contact me: http://andrewu.co.uk/contact/
- Apologies for the wrong timestamp on my post - blame my ISP
Jul 23 '05 #2
Mario wrote:
How to get monitor resolution using javascript?


The question you should be asking is why you want to do this.

The resolution of the "monitor" has only a passing relationship
with the dimensions of the Web browser. It simply defines what
might be the maximum possible *outer* dimensions of the browser
window.

It tells you nothing about how big the *viewport* on the browser
is. Given the ability of browsers with customizable toolbars the
viewport could be anything from a few pixels smaller then the
outer dimensions of the browser to hundreds of pixels smaller (I
once saw a user using Internet Explorer with about 8 toolbars,
their viewport was perhaps 1/3 of the overall height of the outer
dimensions of the Web browser window).

For people with multiple monitor configurations, the dimensions
you retrieve might be the size of all monitors both horizontally
and vertically, not very useful because it's highly unlikely
anyone with 2 or more monitors would maximize a Web browser
across all of their monitors.

If your idea is to "maximize the user's browser for them", this
is an _extremely_ bad idea.

First, it's more and more likely attempting to do such a thing is
simply going to fail due to browser add-ons or built-in ability
to ignore such requests.

Second, people with 2 or more monitors might not appreciate you
spreading their browser window over all their displays (of
course, anyone with 2 or more monitors probably disable your
ability to resize the browser in the first place).

Third, it's really really really RUDE to mess with the user's
browser dimensions. It shows a lack of respect for your visitors
and somehow implies you know better then they do.

All that said, if you want this information for survey purposes
or some other reason, you can retrieve the size of the available
desktop area using:

screen.width and screen.height

To obtain the area of the desktop available to actually display
windows in (minus any taskbars or toolbars) its:

screen.availWidth and screen.availHeight

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq

Jul 23 '05 #3
Mario wrote:
How to get monitor resolution using javascript?


You cannot and even if you could, what would it serve anyway?
Display resolution != desktop size != browser window size != viewport size.
[psf 3.7]
PointedEars
Jul 23 '05 #4

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

Similar topics

10
30400
by: KJM | last post by:
How can I detect if the user has dual monitors and then how do I control which monitor a form is displayed on. Currently my forms always come up on my right monitor. What if I want to have it...
10
11550
by: santiago538 | last post by:
Hi, Is there any way to specify which monitor a Window.open() will launch a new browser window in on systems with more than one display. It would only need to work with Mozilla browsers, and not...
6
4322
by: Yeah | last post by:
I just purchased a Samsung 930B flat-panel monitor. Its *recommended* resolution is 1280x1024. I was previously running at 1024x768, but I also work with graphics. Any images that were square or...
2
2672
by: Bill Nguyen | last post by:
Is there a way to send output from a .NET app to a selected monitor screen in a 3-monitor client desktop? Currently, my app sends output to 3 windows then I have to move/drag each of them to the...
10
1783
by: RobinS | last post by:
Hello to all, and happy new year! I have this application that someone wrote that I'm sort of checking out. The forms look fine in design mode, but when I run the application, it crops off the...
3
3504
by: akbar | last post by:
I googled and searched in archive. All I can find is finding resolution with Tkinter and pygame. Any idea to find monitor resolution with standard python module? I can check from output of: xprop...
2
2632
by: dpicella | last post by:
I have a semi-urgent need to solve a problem in Java. I have three small images that I need to hold to a constant size (e.g., 1 inch) regardless of both monitor size and resolution. Basically...
4
2434
by: =?Utf-8?B?a2F5a28yMDAw?= | last post by:
Hey folks, I'm having a bit of an issue with how Windows Vista (or my ASUS notebook) handles closing my notebook lid. If I have an external monitor (my TV through S-Video) connected to my...
6
5295
by: | last post by:
Hi, I need to get the the display monitor native resolution.I have tried SystemInformation.PrimaryMonitorSize. it is giving the exisiting resolution of the display monitor that is connected....
0
7040
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
7041
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
6908
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4772
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
2994
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2980
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1299
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
561
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
178
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.