Hi,
I'm looking for a javascript that can give me the screensize of a computer.
Can anyone help me?
Thanks 9 1627
Joris De Groote wrote: I'm looking for a javascript that can give me the screensize of a computer. Can anyone help me?
alert(screen.width)
--
Bart
Joris De Groote wrote: I'm looking for a javascript that can give me the screensize of a computer. Can anyone help me?
alert(screen.height)
--
Bart
Joris De Groote wrote: I'm looking for a javascript that can give me the screensize of a computer. Can anyone help me?
Yes, you are mistaken in thinking that the screen size of a computer
has any relevance to anything you will do in a browser window with
javascript. You need to identify what you really need/want to know
before attempting to find out how to get that information.
Richard.
Richard Cornford wrote: Yes, you are mistaken in thinking that the screen size of a computer has any relevance to anything you will do in a browser window with javascript.
I think you're being a bit obtuse.
Client request: "Please make the popup window appear in the middle of my
screen."
This requires knolwedge of screen resolution to implement.
There are cases where it fails (for example, dual monitors causes misleading
numbers) but in the majority of cases, it can be done.
If the OP knows the object/attributes to check and is aware that it may not
always be accurate in all cases, then he can make the decision himself of
whether or not it's appropriate for his situation.
--
Matt Kruse http://www.JavascriptToolbox.com http://www.AjaxToolbox.com
Matt Kruse wrote: Richard Cornford wrote: Yes, you are mistaken in thinking that the screen size of a computer has any relevance to anything you will do in a browser window with javascript. I think you're being a bit obtuse.
Client request: "Please make the popup window appear in the middle of my screen."
This requires knolwedge of screen resolution to implement.
But it also requires knowledge of the screen's disposition (and how
that disposition relates to and screen dimension information
available), and as that information is not exposed by browsers at all
the only honest way of satisfying the client is to ask them about their
specific screen, and tell them that others may not see the same as they
do.
The sensible response is to find out why the client thinks that opening
a window in the middle of the screen is a good idea and then offer them
something that will get the job done (which is probably making the user
aware of something important) in a reliable way that will turn out to
have no interest in screen dimensions.
A dialog opening in the middle of a monitor the user is not even
looking at does nobody any good, while presenting information in the
browser that the user is working with stands a very good chance of
bringing it to their attention.
There are cases where it fails (for example, dual monitors causes misleading numbers) but in the majority of cases, it can be done.
You are forgetting pop-up blockers (not being able to open a window at
all).
You are also forgetting semi-permanent desktop features (such as the
task bar) which may significantly alter the value of putting a window
in the middle of the screen.
When choosing between options success in some majority of cases
combined with total failure in the rest is not as good a choice as
success in a larger proportions of cases and only degraded behaviour in
the rest. Bare in mind that picking on the standard dimensions
displayed on a 17 inch monitor will also 'work' in the vast majority of
cases. That really is not much of an achievement.
If the OP knows the object/attributes to check and is aware that it may not always be accurate in all cases, then he can make the decision himself of whether or not it's appropriate for his situation.
You want an informed decision, then what is wrong with telling someone
that they are mistaken in thinking that the screen size of a computer
has any relevance to anything they may want to do in a browser window?
If they are going to do it anyway knowing the required information is
either not available or not reliable then the dimensions did have no
relevance.
Richard.
Richard Cornford wrote: the only honest way of satisfying the client is to ask them about their specific screen, and tell them that others may not see the same as they do.
Which may be acceptable. Maybe it's a webapp, and the browser/os
configuration is known. The requirement can be met.
The sensible response is to find out why the client thinks that opening a window in the middle of the screen is a good idea and then offer them something that will get the job done (which is probably making the user aware of something important) in a reliable way that will turn out to have no interest in screen dimensions.
Perhaps. Or maybe they want a popup to appear in the center of the screen!
A dialog opening in the middle of a monitor the user is not even looking at does nobody any good
Agreed, so if dual monitors is the case, then another solution should
probably be found.
Also, dialogs aren't the only reason for wanting screen dimensions.
What if a webapp has a 'control panel' which they want to popup in the upper
right corner of the screen by default? What do you tell them? "Sorry, I
*could* do that, and it would work for all your users, but I don't want to,
because you shouldn't want that anyway."
You are forgetting pop-up blockers (not being able to open a window at all). You are also forgetting semi-permanent desktop features
I'm not forgetting anything. Popping up a window is just one case where
screen dimensions might be handy.
Just because someone wants an answer doesn't mean they need to solve 100% of
possible cases. They may only be looking to solve a subset of all possible
conditions, which might be very doable.
When choosing between options success in some majority of cases combined with total failure in the rest is not as good a choice
You're assuming that "total failure" is a possibility. Maybe it's not.
You want an informed decision, then what is wrong with telling someone that they are mistaken in thinking that the screen size of a computer has any relevance to anything they may want to do in a browser window?
If you told the OP some reasons why they might want to consider other
options, that might be helpful. Just telling them that they shouldn't do
what they think they want to do, with no reasoning behind it, is just
annoying.
--
Matt Kruse http://www.JavascriptToolbox.com http://www.AjaxToolbox.com
"Matt Kruse" <ne********@mattkruse.com> writes: Perhaps. Or maybe they want a popup to appear in the center of the screen!
That should be discouraged. I use a browser with an MDI interface, so
it's pretty likely that the center of the screen is not available to
a web page window at all, and even if it is, positioning will almost
certainly fail.
What if a webapp has a 'control panel' which they want to popup in the upper right corner of the screen by default?
Again, it would fail in my browser (but it might succeede in popping
up in the upper right corner of my browser application window).
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Lasse Reichstein Nielsen wrote: Perhaps. Or maybe they want a popup to appear in the center of the screen! That should be discouraged.
Maybe in an internet context. But for an intranet or webapp, it might be
desired. What if a webapp has a 'control panel' which they want to popup in the upper right corner of the screen by default? Again, it would fail in my browser (but it might succeede in popping up in the upper right corner of my browser application window).
And my point was, if your browser environment was typical of one that needed
to be supported by the design, then popping up in any position would be a
bad idea. Otherwise, if the known browser environment would support such a
popup, it would work just fine.
--
Matt Kruse http://www.JavascriptToolbox.com http://www.AjaxToolbox.com
Matt Kruse wrote: Richard Cornford wrote: the only honest way of satisfying the client is to ask them about their specific screen, and tell them that others may not see the same as they do. Which may be acceptable.
It is not supposed to be acceptable, it is intended to make it clear to
the individual with the ill-considered requirement that they are
thinking too much in terms of their personal situation and not
considering the bigger picture.
It is almost universal that individuals unconsciously assume that
everyone will interact with software in exactly the same way that they
do. Even putting aside accessibility considerations, the mindset that
has everyone using a mouse to interact with a browser makes proposal
that work with a mouse and disregards the possibility of keyboard use,
while there are plenty of individuals who will be preferring a keyboard
for interaction. It is part of the job of a software designer to take
their self-centred requirements and accommodate the unconsidered
alternatives in the resulting design.
If that requires that the individuals making the ill-thought-out
requirement be made to understand the real situation and maybe
re-state/word their requirement in a more suitable form then that is
what should happen. The customer may always be 'right', but the customer
should be employing someone else to design their software so that
process includes someone who knows which bigger picture needs to be
considered in the design.
Maybe it's a webapp, and the browser/os configuration is known. The requirement can be met.
Doesn't the fact that a major factor in rendering screen dimensions
un-useful is the possibility of mult-monitor configurations require that
hardware configurations also be full known? The sensible response is to find out why the client thinks that opening a window in the middle of the screen is a good idea and then offer them something that will get the job done (which is probably making the user aware of something important) in a reliable way that will turn out to have no interest in screen dimensions.
Perhaps. Or maybe they want a popup to appear in the center of the screen!
You are proposing that this is no more than an idle whim? Surly that is
only significant if it is a whim that is informed by an understanding
that its consequences may be poor or bad for some, otherwise making the
pertinent points may modify the whim into something more reasonable. A dialog opening in the middle of a monitor the user is not even looking at does nobody any good
Agreed, so if dual monitors is the case, then another solution should probably be found.
And the only means of knowing whether multi-monitors is the case is
knowing the specific hardware in use, it cannot be reliably detected.
Also, dialogs aren't the only reason for wanting screen dimensions.
The reasons for wanting to know screen dimensions mostly only exist in
the ignorance of the uselessness of the information those dimensions
represent.
What if a webapp has a 'control panel' which they want to popup in the upper right corner of the screen by default?
It does not make sense to want your "control panel" to be placed where
it would be partly obscured by a task bar located to the left or top of
the display. Much as it does not make sense to put it in location where
the user may not be aware of its presence at all.
You may perceive the need for the screen dimensions in order to stratify
a poorly thought-out design, but fix the design an the interest in the
screen dimensions evaporates.
What do you tell them? "Sorry, I *could* do that, and it would work for all your users, but I don't want to, because you shouldn't want that anyway."
Why would I say that when in reality is may fail for any of their users? You are forgetting pop-up blockers (not being able to open a window at all). You are also forgetting semi-permanent desktop features
I'm not forgetting anything.
Then why have you proposed the top-left of the screen as an appropriate
location for a "control panel"?
Popping up a window is just one case where screen dimensions might be handy.
It is no, it is a case where thinking in terms of screen dimensions is
missing important aspects of reality.
Just because someone wants an answer doesn't mean they need to solve 100% of possible cases.
And you think that is a reason for ignoring issues that can be
addressed?
They may only be looking to solve a subset of all possible conditions, which might be very doable.
If people provide the context information related to their questions
then they may get answers tailored to that context, otherwise they get
what they get. When choosing between options success in some majority of cases combined with total failure in the rest is not as good a choice
You're assuming that "total failure" is a possibility. Maybe it's not.
There are so many possible failure scenarios following form actually
using browser reported screen dimensions that the few extremely
specialised cases where total failure is excluded cannot justify
brushing the issues aside without certain knowledge of the applicability
of the special case. You want an informed decision, then what is wrong with telling someone that they are mistaken in thinking that the screen size of a computer has any relevance to anything they may want to do in a browser window?
If you told the OP some reasons why they might want to consider other options, that might be helpful. Just telling them that they shouldn't do what they think they want to do, with no reasoning behind it, is just annoying.
Above you are attempting to make the point that there are potentially a
wide range of conditions that may lead someone to believe that they
should have an interest in screen dimensions. Are you proposing that I
run through all of them (or at lest the couple of dozen that may come to
mind at any the time) and enumerate the issues, possibilities and
alternatives for each?
It makes much more sense to me to propose that the question implies a
fundamental misconception and leave it to the OP to render the situation
concrete enough for practical strategies to be proposed.
And what alternative are you proposing? Someone spitting out -
screen.width/height - and leaving the OP to add yet another poorly
though-out script to the Internet?
Richard. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Nathan Sokalski |
last post by:
I want to determine the operating system using ASP (or VBScript inside of
ASP). I tried to get it using the Request.
ServerVariables(EnvironmentVariable) method. On the web page about ASP in
which...
|
by: Shahid Juma |
last post by:
Hello All,
This may be a trivial question, but I was wondering how can you determine if
a value contains an Integer or Float. I know there is a function called
IsNumeric, however you can't...
|
by: Hennie de Nooijer |
last post by:
Hi, This is a diffcult issue to explain. I hope to make my problem
clear to you.
SITUATION
I'm building A SLA Query for a customer. This customer has an awkward
way to determine the SLA results...
|
by: lucpustjens |
last post by:
Hello,
I want te determine the client operating system, because I need to kno
the default cookie directory. If there is a way to determine the cooki
directory directly, than it is also good.
...
|
by: Christopher W. Douglas |
last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a
method that handles several events, such as closing a form and changing the
visible status of a form. I have some code...
| |
by: lauren quantrell |
last post by:
Is there a way to determine the size of the user's screen minus the
Windows task bar?
I am trying to maximize an Access popup form that is also resizeable
and it is causing me problems since it...
|
by: Adam |
last post by:
Can someone please help!!
I am trying to figure out what a font is?
Assume I am working with a fixed font say Courier 10 point font
Question 1: What does this mean 10 point font
Question 2:...
|
by: semedao |
last post by:
Hi all,
I view many posts about this issue , the connected property does not tell us the current status of the socket.
based on couple of suggestions of msdn , and some article here , I try to...
|
by: Jana |
last post by:
Greetings Access Gurus! I am working on an app to send batch
transactions to our bank, and the bank requires that we place an
effective date on our files that is 'one business day in the future,...
|
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...
|
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,...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |