Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Javascript JavaScript resizeBy() method

Related Tutorials


 
 

Share on Google+Share on Google+

JavaScript resizeBy() method

Advertisement
We can resize window by using the method resizeBy(). It resizes the window into the specified pixels passed as parameters to this method.

JavaScript resizeBy() method

     

We can resize window by using the method resizeBy(). It resizes the window into the specified pixels passed as parameters to this method.

Syntax :

window.resizeBy( width, height );

where width and height both are necessary and these can be any positive or negative number. It denotes width and height in pixels.

Description of code:

To illustrate the use of resizeBy() method we have created a simple HTML page into which we have created two input boxes for taking width and height values by the user. We also have created a button "Resize Window" which calls the function resizeWindow() on mouse click event. This function is defined in <script></script> tags.

 function resizeWindow(){
   var wdth =document.getElementById("txtWidth").value;
   var hgt =document.getElementById("txtHeight").value;
   window.resizeBy(wdth,hgt);
 } 

In above lines of code we have first taken width and height input values into the two variables wdth and hgt and thereafter we will set the window size by these width and height values accordingly by using method.

 window.resizeBy(wdth,hgt);

Full example code is as given below :

<html>
<body>
<script language="JavaScript">
 function resizeWindow(){
   var wdth =document.getElementById("txtWidth").value;
   var hgt =document.getElementById("txtHeight").value;
   window.resizeBy(wdth,hgt);
 } 
</script>
<div style="background: #ff9900; width:'100%';"
          align="center">
  <font color="#0000ff" size="12pt">
	<b>ResizeBy Example</b>
  </font>
 </div>
  <center>
   <div style="background: #0099ff; width:'100%';" 
        align="center">
    <form id="userForm" >
     <p>Width <input type="text" id="txtWidth" /></p>
     <p>Height<input type="text" id="txtHeight" /></p>
     <p> <input type="button" value="Resize Window" 
           onClick="resizeWindow()"/></p>
    </form>
   </div>
 </center>
</body>
</html>

Output :

Input width and height into text boxes to resize window.

Again resizing window you can see the difference.

You can also download full code from the following link

Download Source Code

     

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: February 7, 2009

Related Tutorials

Discuss: JavaScript resizeBy() method  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com