如何为指定的Java代码打开一个新窗口

时间:2014-04-06 17:47:00

标签: javascript new-window

我在页面上有以下代码。有用。我只是无法找到如何在新窗口中打开它。 window.open不会对它起作用。 需要帮助。

<form method="post">
<input type="RADIO" name="button" value="index1.html" checked>this button goes to index1.html (Default)<BR>
<input type="RADIO" name="button" value="index2.html">this button goes to index2.html<BR>         
<input type="RADIO" name="button" value="index3.html">this button goes to index3.html<BR>
<input type="submit" value="Continue">


<script>
$(function(){
$("form").submit(function(e) {
    e.preventDefault();
    window.location = $(this).find('input[type="radio"]:checked').val();
});
});
</script>

</form>

1 个答案:

答案 0 :(得分:2)

以下是一个适用于您的更新:window.open:

http://jsfiddle.net/yQLmL/

<form method="post">
    <input type="RADIO" name="button" value="http://www.google.com" checked>this button goes to index1.html (Default)
    <BR>
    <input type="RADIO" name="button" value="http://www.yahoo.com">this button goes to index2.html
    <BR>
    <input type="RADIO" name="button" value="http://www.stackoverflow.com">this button goes to index3.html
    <BR>
    <input type="submit" value="Continue">
</form>

<script>
    $(function () {
        $("form").submit(function (e) {
            e.preventDefault();
            var url = $(this).find('input[type="radio"]:checked').val();
            window.open(url);

        });
    });
</script>