Solved

html (or other code) to detect screen resolution and change to 1024x768 from different resolutions

Posted on 2008-10-21
6
2,089 Views
Last Modified: 2013-11-19
I have a friend in IT who is web mastering an intranet site where I work and he needs some coding help (with the appropriate language, Java, .asp, .html, whatever) to make sure the screen resolution on each computer of each user is 1024x768 whenever this site is accessed (We are using Windows XP Pro). Please feel free to ask for more info, if necessary.
0
Comment
Question by:gtgloner
6 Comments
 
LVL 11

Expert Comment

by:MacNuttin
ID: 22767270
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 22767296
Hello gtgloner,

I would say that this is a really bad idea! Anything that changes the screen resolution of my computer (or any other aspect of its configuration) would be instantly binned. I understand that this is an intranet and your users may well be strictly regulated, even so it is a bit much to change a user's resolution just to fit the design of your page. In fact it is completely the wrong way to approach it. If you cannot (for whatever reason) or will not design the site in such a way as it can adapt seamlessly to the resolution in use on the client then you can opt to design to a fixed size using CSS. Alternatively you can resize the browser window to a known and fixed size using window.sizeTo(1024,768). Even this is not necessarily user-friendly, it would be better to popup a new window with your fixed size.s

Regards,

TimCottee
0
 
LVL 7

Expert Comment

by:mltsy
ID: 22767784
What I would do is design your site with a fixed width, and then check the user's screen size (screen.width) and alert them if it is too small:
<head>

<style type="text/css">

  body {

    width:1000px;

  }

</style>

<script type="text/javascript">

  function body_onLoad() {

    if(screen.width < 1024) alert("This page is best viewed with your resolution set to 1024x768.  [Explanation, who to call for help, etc]");

  }

</script>

</head>
 

<body onLoad="body_onLoad()">

  ...

</body>

Open in new window

0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 7

Expert Comment

by:mltsy
ID: 22767816
You could also check window.innerWidth to check the actual size of the browser window, and say "This site works best with your browser maximized at a resolution of 1024x768."
0
 
LVL 17

Author Comment

by:gtgloner
ID: 22769342
Here is my friend's response to the comments:

"So far the responses are about how to check the screen resolution.  What we need is a way through html or java to change the resolution on the fly."

So, what he wants to know is, can this be done?
0
 
LVL 43

Accepted Solution

by:
TimCottee earned 500 total points
ID: 22769502
As I suggested back up there, using javascript you can set the browser window size:

<body onload="window.sizeTo(1024,768);">

For example. This will not affect the workstation itself but will ensure that the browser window is set to the required size. You can also add it to the resize event handler so that it will always remain the same size.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now