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

时间:2013-10-04 02:14:53

标签: javascript forms input submit

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

<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>

感谢您提供的任何帮助。

1 个答案:

答案 0 :(得分:1)

尝试更改此

 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属性。所以如果你必须在双引号中引用,那么教训是使用单引号。

相关问题