繁体   English   中英

在新标签页中打开的表单无法正常工作

[英]Form to open in new tab not working

这种形式有两个问题:

  1. 尽管我添加了target =“ _ blank”,但提交时,第一个表单不会在新标签页中打开
  2. 单击“登录”按钮时,直到新打开的选项卡关闭或完全加载,当前表单才会冻结。 我似乎不知道为什么!

HTML:

<form target="_blank" onsubmit="window.location = 'http://sub1.domain.com?tt=' + search.value; return false;">
                <label><input type="radio" name="optradio" value="1"> Tracking ID</label>  &nbsp; 
                <label><input type="radio" name="optradio" value="2" > OPC</label>
<div id="Track1" class="desc" style="display: none;">
                <br />
                <input id="search" class="TrackInput" onclick="this.placeholder=''" onblur="this.placeholder='IYIUY'" type="text" placeholder="IYIUY" type="search" name="search">
                <br />
<button type="submit" value="Submit">Track</button>
</div>

<div id="Track2" class="desc" style="display: none;">
<a href="http://sub2.domain.com" target="_blank">LOGIN</a>
</div>
</form>

JS:

$(document).ready(function() {
    $("input[name$='optradio']").click(function() {
        var test = $(this).val();

        $("div.desc").hide();
        $("#Track" + test).show();
    });
});

有人可以对这两个问题为何都发生了一些想法吗?

演示JSFiddle

您已在form onsubmit event添加了return false

onsubmit="window.location = 'http://sub1.domain.com?tt=' + search.value; return false;">

return false将阻止其默认操作。 因此,只需删除最后的return false 其他一切看起来都不错。

Updated Fiddle

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM