Solved

Window reload when the user change the screen resolution.

Posted on 2004-08-30
8
894 Views
Last Modified: 2009-12-16
Hi,

Can any body help me.

I want to reload the page when a user changes his screen resolution (800 x 600) to (1024 x 768) and vice versa.

This can be done using javascript. Does any one have a browser compatible code snippet of this functionality.

Pls reply if you have such.

Thanks,

Sumit Shah.
0
Comment
Question by:sumitshahmphasis
8 Comments
 
LVL 4

Accepted Solution

by:
PeterCN earned 60 total points
ID: 11939648
It seems a bit unlikely to me that a user will change his or her resolution during a visit on any site. Or ever for that matter. Why change it when it's ok?

You could use a timeout or interval to look at the screen.width (and screen.height) properties. Store them in a var onload, and use the stored values as a reference when checking in the timeout function. So yes, it's possible, but again, it seems a bit useless to me.

demo:

<html>
<head>
      <script type="text/javascript">

      window.onload = function() {
            screenWidth = screen.width;
            setInterval('checkResolution()', 1000)
      }

      function checkResolution() {
            if(screenWidth != screen.width) {
                  alert('user changed resolution!');
                  screenWidth = screen.width;
            }
      }

      </script>

</head>
<body>
</body>
</html>
0
 
LVL 8

Assisted Solution

by:_aaron_
_aaron_ earned 60 total points
ID: 11939800
This function fires whenever the window size is changed... dependent on your code, you might just want to put in something like "document.reload(true)"....

<script>
function window.onresize()
{
   // Do Something...
   alert()
}
</script>

<body>


</body>
0
 
LVL 8

Expert Comment

by:_aaron_
ID: 12306087
@Venabili

Seems odd that the Author didn't respond to the onresize solution, it fires each time the window / screen is resized; its a fairly simple solution to a fairly simple problem... In relation to browser compatibility, the onresize is core to most ( if not all ) browsers ( as far as I am aware )...


Thanks,
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 4

Expert Comment

by:PeterCN
ID: 12434071
The onresize event is only fired when changing the screen resolution if the window is too large to fit the new resolution. This is, however, assuming that sumitshahmphasis indeed meant the screen resolution, and not simply the window size.
0
 
LVL 11

Expert Comment

by:huntersvcs
ID: 12768477
Hello Venabili
I think this one slipped through the cracks - I don't see it ever being closed :-)
0
 
LVL 19

Expert Comment

by:dakyd
ID: 15646103
No comment has been added to this question in more than 21 days, so it is now classified as abandoned..
I will leave the following recommendation for this question in the Cleanup topic area:

SPLIT PeterCN, _aaron_ -- http://Q_21113291.html#11939648, http://Q_21113291.html#11939800

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

dakyd
EE Cleanup Volunteer
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

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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)
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…

932 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

15 Experts available now in Live!

Get 1:1 Help Now