resizeTo(x,y) and resizeBy(xDelta,yDelta)

In this chapter you will learn:

  1. How to resize a window in Javascript

Resize a window

The browser window can be resized using the resizeTo() and resizeBy() methods. resizeTo() expects a new width and height and resizeBy() expects the differences in each dimension.

<!DOCTYPE HTML> <!--   j a  va2  s.c  o  m-->
<html> 
    <body> 
        <script type="text/javascript"> 
            
                //resize to 100 x 100 
                window.resizeTo(100, 100); 
                //resize to 300 x 300 
                window.resizeTo(300, 300); 
                //resize to 200 x 150 
                window.resizeBy(100, 50); 
                
        </script> 
    </body> 
</html>

Click to view the demo

Next chapter...

What you will learn in the next chapter:

  1. How to scroll a window
Home » Javascript Tutorial » Window
Window Object
alert()
close()
confirm()
find()
Window height and width
location
window.moveBy
window.moveTo
window.open()
window.print()
window.prompt()
resizeTo(x,y) and resizeBy(xDelta,yDelta)
window.scrollTo(x,y)
screenLeft, screenX, screenTop, screenY
setInterval()
setTimeout()