CodeAve.com CodeAve.com - JavaScript - Misc
ASP
JavaScript
·Document Info
·Forms
·Images
·Miscellaneous
·Navigation
·Script Writers
·Contents
·What's New?
CSS
HTML
Maps
Links
Mail List
Search
Sitemap


 


Move and Resize the Browser Window
There may be occasions where you will want to implicitly instruct the browser how big is should appear and where on the desktop you want it to appear. The following examples contain a couple of functions that will resize and position the window on opening or when any one of the links contained in the page is clicked, some re-size functions are based on hard-coded values, others that will resize based on the available screen size on the client.
View the Output
Text View
Print View
Mail this Link
Download the Code

<html>
<title>CodeAve.com(Move and Resize Window)</title>
<body bgcolor="#FFFFFF">
<script language="JavaScript">
<!--
// This will move the window when it is opened or
// refresh/reload is clicked to a location zero pixels to the left
// and zero pixels from the top. Left command goes first,
// top to bottom comes after
self.moveTo(0,0)
 
// This will resize the window when it is opened or
// refresh/reload is clicked to a width and height of 500 x 500
// with is placed first, height is placed second
self.resizeTo(500,500)
-->
</script>
 
When the window is opened or
refresh/reload are clicked
<br>the window will move to zero from the left and zero from the top
<br>and set a browser window width and height of 500 x 500
 
<script language="JavaScript">
<!--
// function to allow the moving of the window location by link
// to a location of 400 pixels from the left and 300 pixels from the top
function move_2_400_300()
{
self.moveTo(400,300)
self.resizeTo(400,300)
}
-->
</script>
<br>
Click <a href="javascript:move_2_400_300();">here</a> to move
the window to 400 pixels from the left and 300 pixels from the top
<br>and set a browser window width and height of 400 x 300
 
 
 
<script language="JavaScript">
<!--
// function to allow the moving of the window location by link
// to a location of 1/2 the screen from the left
// and 1/2 the screen from the top
function move_2_half_half()
{
self.moveTo(screen.width/2,screen.height/2)
self.resizeTo(screen.width/2,screen.height/2)
}
-->
</script>
<br>
Click <a href="javascript:move_2_half_half();">here</a> to move
the window to 1/2 way from the left and 1/2 way from the top
<br>and set a browser window width and height of 1/2 of their maximum size
 
<script language="JavaScript">
<!--
// This function will move the window when when clicked
// to a location zero pixels to the left and zero pixels from the top.
self.moveTo(0,0)
function move_2_0_0()
{
self.moveTo(0,0)
self.resizeTo(screen.width,screen.height)
}
-->
</script>
<br>
Click <a href="javascript:move_2_0_0();">here</a> to move
the window to zero pixels from the left and zero pixels from the top
<br>and set a browser window width and height to their maximum size
 
</body>
</html>

 

 

 



ASP: What's New? | Articles | Script Writers | Database Display | Read/Write
Server Variables | Response Objects | Random Events | Miscellaneous
HTML: Forms | Hyperlinks | Headers | Tables | Hyperlinks | Headers | Text Display
JavaScript: Document Info | Forms | Images | Navigation | Script Writers
CSS: Basics | Page Display | Text Display | Script Writers | Miscellaneous
Maps: Map Script Writers | Bing Maps | Google Maps
Privacy Statement

CodeAve.com is hosted by MyHosting.com
Donate Food Online with a Mouse Click at TheHungerSite.com
Donate Land Online with a Mouse Click at TheRainForestSite.com
© 1999 - 2013 CodeAve.com
All Rights Reserved