Search code examples
javascripthtmlcssformsportrait

Hyperlink that Opens into Portrait Formatted Window With Specific Dimensions


enter image description here

This page has to open up in Portrait format with the dimensions 400 x 350 (px). I'm not sure if I need to use javascript or CSS to achieve this, but this is what I tried:

link from "index.html" that links to the new page, "form.html":

<a style="text-decoration:none" href="form.html">Request
Information</a>

HTML for "form.html":

<html>
<head>
<title>Sean's Hardware Store</title>
<script src="form.js"></script>
</head>
<body leftmargin=0 rightmargin=0>
<br>
<table width=100% border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=95% align=right bgcolor=#ffffff>
<img src="logo.jpg"><br>
<font face=arial></font>    </td>
<td bgcolor=#ffffff>&nbsp;</td>  
</tr>
</table>
<br><br>
<center>
<table width=85%>
<tr>
<td valign=top>
<form method=post action="">
    Name:<br>
<input name="textname" size=35><br><br>
E-mail:<br>
<input name="textname" size=35>
<br><br>
<input type=submit name="button1" value="Submit">
</form>
</td>
</tr>
</center>
</body>
</html>

Javascript:

window.onload=function() {
  document.getElementById("window").onchange=function() {
  window.open("","newWin","width=400,height=350");
  setTimeout(function() {
    document.forms[0].submit();
    },100);// allow IE to get over the shock of opening a window
  }
}

Also, can index and form be linked to the same javascript file? Right now I have two separate js files because I don't want them to interfere with one another (index also has some js). Thank you.


Solution

  • You can do it straight from your HTML like this:

    <a href="form.html" onclick="window.open(this.href,'targetWindow',
    'toolbar=no, location=no, status=no, menubar=no, scrollbars=yes,
    resizable=yes,width=400, height=350');
    return false;">Request Information</a>