JavaScript Crazy Window Zoomer

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.

function warpSpeedWindow(){
 for(i = 0;i < 50;i++){
  window.moveTo(screen.availWidth * -(i - 50) / 100, screen.availHeight * -(i - 50) / 100);
  window.resizeTo(screen.availWidth * i / 50, screen.availHeight * i / 50);
 window.resizeTo(screen.availWidth, screen.availHeight);

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.


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 < 50;i++){window.moveTo(screen.availWidth * -(i - 50) / 100, screen.availHeight * -(i - 50) / 100);window.resizeTo(screen.availWidth * i / 50, screen.availHeight * i / 50);}window.moveTo(0,0);window.resizeTo(screen.availWidth, screen.availHeight);
thanks for the bookmarklet. I've given it a go and it works!
Philip Norton

Add new comment

The content of this field is kept private and will not be shown publicly.
13 + 4 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.