form表单提交不跳转

来源:互联网 发布:node schedule 不好使 编辑:程序博客网 时间:2024/05/29 14:33

form表单中的 target的作用是让form提交后在什么窗口下打开,有时候只需要往后台传值,并不需要打开新窗口,可采用写个看不见的iframe

这样我们写一个iframe,像下面这样设置这个iframe是看不到的。

<form method="post" target="posthere" action="user-login"> 
<iframe name="posthere" frameborder=0 width=0 height=0></iframe>

最终,form表单提交会打开iframe,但iframe被我们设置成看不见的,这样form提交时就刷新不跳转

原创粉丝点击