Solved

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

Posted on 2008-10-21
6
2,100 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

813 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

16 Experts available now in Live!

Get 1:1 Help Now