JavaScript Crazy Window Zoomer

26th August 2008 - 2 minutes read time

I really don't know how this would be useful, but it might teach you a couple of things about how to use the browser window functions and properties.

The following function resizes the browser window to nothing and then gradually increases this to full screen in a series of steps, at each step the window is moved so that it is in the middle of the screen. This in effect makes it look like the browser window is zooming in.

  1. function warpSpeedWindow(){
  2. for(i = 0;i < 50;i++){
  3. window.moveTo(screen.availWidth * -(i - 50) / 100, screen.availHeight * -(i - 50) / 100);
  4. window.resizeTo(screen.availWidth * i / 50, screen.availHeight * i / 50);
  5. }
  6. window.moveTo(0,0);
  7. window.resizeTo(screen.availWidth, screen.availHeight);
  8. }

You can call this function on the page load by using the following:

<script type="text/javascript" language="javascript">warpSpeedWindow();</script>

This is a fun little thing to do and should be used for educational purposes only. Please refrain from doing this on a live site. Any user who sees this effect is likely to think that the site is very unprofessional and go elsewhere.

Comments

Permalink
Also, you can do this to any site, even if you are not the owner. All you need to do is insert the javascript code into the URL address bar and it will work on the current site. EG: (copy and paste this into your Address bar, but remember to have it all on ONE line!!!) javascript:for(i = 0;i

Jamie Bicknell (Tue, 08/26/2008 - 22:00)

Add new comment

The content of this field is kept private and will not be shown publicly.