javascript - 打开具有特定尺寸的纵向格式窗口的超链接

标签 javascript html css forms portrait

enter image description here

此页面必须以纵向格式打开,尺寸为 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>&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
  }
}

此外,索引和表单可以链接到同一个 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/

相关文章:

html - JSTL可以用在HTML页面吗?

php - 帮助在 Yii 中显示图片库

javascript - 使用 JQuery 在 HTML div 之后添加 CSS 类

javascript - Twitter Bootstrap Accordion 功能

javascript - 如何防止前 4 次点击链接点击的默认行为

JavaScript 从变量 getElementById

javascript - Bootstrap 下拉菜单错误的地方

javascript - 运行 AJAX 代码时,行总和不会更新,直到 F5 刷新

html - 如何使 HTML 表格列尽可能紧密地压缩? (或者,尽可能地成长?)

html - 用于页面布局的 Flexbox?