一个提交按钮打开两个页面 - 一个新窗口中

One submit button opens two pages - one in a new window

本文关键字:一个 新窗口 窗口 按钮 提交 两个      更新时间:2023-09-26

我的网站上有一个邮政编码提交按钮。当用户按下提交按钮时,我希望当前页面(自我)转到不同的页面(结果)以及新的选项卡/页面打开。这是我正在使用的。我遇到的问题是第二个窗口打不开。其他一切都有效。我没有太多编码经验。我通过搜索将其拼凑在一起。

<form id="header-box-form" action="http://www.quotesfortermlife.com/results.html" method="get">
    <input type="text" onkeypress="return submitenter(this,event)" maxlength="10" size="16" id="zipcode" name="zipcode" tabindex="1">
<input onmouseover=
                    "this.src='http://www.quotesfortermlife.com/pictures/orng_btn02.png';"
                          onmouseout="this.src='http://www.quotesfortermlife.com/pictures/orng_btn01.png';"
                          onclick=
                          "newWindow('http://www.quotesfortermlife.com/compare-rates.html','window2');window.open('http://www.quotesfortermlife.com/results.html','_self',' ')"
                          src="http://www.quotesfortermlife.com/pictures/orng_btn01.png"
                          type="image">
</form>

感谢您提供的任何帮助。

尝试更改此设置

 onclick="javascript:window.open("http://www.quotesfortermlife.com/compare-rates.html","other_window")

对此

onclick="window.open('http://www.quotesfortermlife.com/compare-rates.html','other_window')
首先,"

javascript:"部分是错误的,它只在链接的"href"属性中需要,这被滥用了很多。 其次,因为您的 URL 周围有一个" ,所以它关闭了 onclick 属性。 所以教训是,如果你必须在双引号内引号,就使用单引号。