Resize The Current Window Based On Form Button

[Total: 0    Average: 0/5]

This shows how to have form buttons choose the size of the current window. You press a button, and tada! the window resizes to that specification.

Head Code:

<script type=text/javascript>
function makeWindow(x,y,t) {
  window.resizeTo(x,y);
}
function regular()          {makeWindow(600,400);}
function large()            {makeWindow(800,600);}
function smallmacdefault()  {makeWindow(470,300);}
function smallpcdefault()   {makeWindow(580,300);}
function mediummacdefault() {makeWindow(470,430);}
function mediumpcdefault()  {makeWindow(580,430);}
function largemacdefault()  {makeWindow(470,600);}
function largepcdefault()   {makeWindow(580,600);}
</script>

Body Code:

<FORM>
<center>
<table>
<tr><td align=center colspan=2>Open New Window With These Dimensions</td></tr>
<tr>
<td align=center><INPUT TYPE=BUTTON VALUE="640x480" onClick="regular()"></td>
<td align=center><INPUT TYPE=BUTTON VALUE="800x600" onClick="large()"></td>
</tr>
</table>
<table>
<tr><td></td><td align=center colspan=2>Default Netscape Browser sizes:</td></tr>
<tr><td><B>640 x 480</B></td>
<td><INPUT TYPE=BUTTON VALUE="Mac 470x300" onClick="smallmacdefault()"></td>
<td><INPUT TYPE=BUTTON VALUE="PC 580x300" onClick="smallpcdefault()"></td>
</tr>
<tr><td><B>800 x 600</B></td>
<td><INPUT TYPE=BUTTON VALUE="Mac 470x430" onClick="mediummacdefault()"></td>
<td><INPUT TYPE=BUTTON VALUE="PC 580x430" onClick="mediumpcdefault()"></td>
</tr>
<tr><td><B>1024 x 768</B></td>
<td><INPUT TYPE=BUTTON VALUE="Mac 470x600" onClick="largemacdefault()"></td>
<td><INPUT TYPE=BUTTON VALUE="PC 580x600" onClick="largepcdefault()"></td>
</tr>
</table>
Close this Window: 
<INPUT TYPE=BUTTON VALUE="Close"
onClick="window.close()">
</center>
</FORM>

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *