Solved

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

Posted on 2008-10-21
6
2,092 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Following as example - where do I place this javascript line? 6 31
Auto refresh part of an MVC5 View 7 53
ASP CDO - Limiting Connections 2 36
Download a website to hdd 2 48
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

930 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

11 Experts available now in Live!

Get 1:1 Help Now