此页面必须以纵向格式打开,尺寸为 400 x 350 (px)。我不确定我是否需要使用 javascript 或 CSS 来实现这一点,但这是我尝试过的:
来自链接到新页面的“index.html”的链接,“form.html”:
<a style="text-decoration:none" href="form.html">Request
Information</a>
“form.html”的 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> </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
}
}
此外,索引和表单可以链接到同一个 javascript 文件吗?现在我有两个单独的 js 文件,因为我不希望它们相互干扰(索引也有一些 js)。谢谢。
最佳答案
您可以像这样直接从 HTML 中执行此操作:
<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>
关于javascript - 打开具有特定尺寸的纵向格式窗口的超链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33138372/