JS代码:

<script type="text/javascript" src="jquery-1.2.6.js" ></script>
<script>
function windowOpen(){
 var toDay = new Date();
 winName = "win"+toDay.getTime();//为了保证提交不会读取本地的缓存
 $("#form1").attr("action","test2.html");//设置form表单提交的URL路径 是 test2.html

//为了表示区分,window.open 打开的是 test3.html
 window.open("test3.html",winName,"status=yes,toolbar=no,menubar=no,location=no");

 $("#form1").attr("target",winName);
 $("#form1").submit();

//代码走到这里之后,将会提交到window.open中的窗口,页面是test2.html
}
</script>

html代码:

<form id="form1" method="post" onsubmit="windowOpen()" >
 <input type="submit" value="提交打开新的页面" />
</form>

知识点:

1、form的target属性,可以设置window的name,为目标窗体 
2、window.open第二个参数,是它的name。 
winName需要设置成一个不重复的id,否则再次点击只会刷新已经打开的window,而不会打开新页面。

Logo

欢迎加入DeepSeek 技术社区。在这里,你可以找到志同道合的朋友,共同探索AI技术的奥秘。

更多推荐