博主辛苦了,我要打赏银两给博主,犒劳犒劳站长。
【摘要】今晚一个同学问我如何在form表单提交数据的时候,在新的窗口打开数据处理页面,当时我也没有想到什么好的方法,就以为是需要用到js或者jQuery才能够实现,其实使用form标签的target属性也是能够实现的,起初一直以为只有a标签才有target属性,其实form表单除了有method和action这个两个最重要的属性之外,还有target属性。
提交表单,然后在新的窗口中打开其实就是form的一个属性:target="_blank"就能够解决问题了。
form表单包括的属性:
完整代码示例:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>提交表单,在新窗口打开</title>
<style type="text/css">
*{margin:0;padding:0;font-size:12px;}
table{margin:200px auto;border:1px solid #999;border-radius:4px;padding:20px 10px;}
table td{line-height:30px;}
</style>
</head>
<body>
<form method="post" action="1.php" target="_blank">
<table cellspacing="0" cellpadding="0">
<tr>
<td>昵称:</td>
<td><input type="text" name="username" /></td>
</tr>
<tr>
<td>密码:</td>
<td><input type="password" name="pwd" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="submit" value="提交" /></td>
</tr>
</table>
</form>
</body>
</html>
执行效果图:
版权归 马富天个人博客 所有
本文标题:《提交表单,在新窗口打开》
本文链接地址:http://www.mafutian.com/198.html
转载请务必注明出处,小生将不胜感激,谢谢! 喜欢本文或觉得本文对您有帮助,请分享给您的朋友 ^_^
顶0
踩0
第 1 楼 月小升 2016-09-14 11:20:22 江苏苏州
评论审核未开启 |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
||