码迷,mamicode.com
首页 > Web开发 > 详细

html 标签: image也能提交form!!!

时间:2017-06-15 19:36:12      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:pop   结果   ack   注意   set   function   title   space   表单   

html 标签: image也能提交form!

!!


image也能提交form

先前常常使用“<input type="submit" value="input_submit"/>” 来提交form

今天在项目中进行开发的过程中有这么一个功能:

点击“XXX”button,进行form表单的提交,可是这个提交button是一个type="image" 的input;

找了半天也没看到这个图片元素绑定的js提交表单的相关信息。

后来向度娘问了下,原来:【image也能提交form!!。】


实践(IE8、firefox 33.1

下面是我做的几个实验(IE8、firefox 33.1下的运行结果不同)。

这里要重点注意:假设image标签用不好,会出现2次提交的问题


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>【注意: image也能提交form!

。 IE8、firefox 33.1下版本号调试】</title> <script type="text/javascript"> function formSubmit(){ alert("It is not a Joke! It is true~~"); document.jokeForm.action = "notAJoke.do?method=justATest"; document.jokeForm.submit(); return true; } </script> </head> <body> <form name="jokeForm" method="post" action="aJoke.do"> <input name="user_name" value="" /><br /> <input name="user_pass" value="" /><br /> <!-- 下面写法,IE8、firefox 33.1 均仅仅提交【1】次:/aJoke.do --> <!-- <input type="image" src="abc.gif"/> --> <!-- 下面写法。<span style="background-color: rgb(255, 102, 102);">IE提交【2】次:/notAJoke.do ,firefox 33.1 提交【1】次</span> --> <!-- <input type="image" src="http://avatar.csdn.net/A/D/0/3_jackpk.jpg" onclick="formSubmit()"/> --> <!-- 下面写法,<span style="background-color: rgb(255, 153, 102);">IE提交【2】次:/notAJoke.do 。firefox 33.1 提交【1】次</span> --> <!-- <input type="image" src="http://avatar.csdn.net/A/D/0/3_jackpk.jpg" onclick="formSubmit();return true;"/> --> <!-- 下面写法。<span style="background-color: rgb(255, 255, 102);">IE8、firefox 33.1 均仅仅提交【1】次:</span>/aJoke.do --> <!-- <input type="image" src="http://avatar.csdn.net/A/D/0/3_jackpk.jpg" onclick="<span style="background-color: rgb(255, 255, 102);">return true;</span>"/> --> <!-- 下面写法,I<span style="background-color: rgb(255, 255, 102);">E8、firefox 33.1 均【无提交】 </span>--> <!-- <input type="image" src="http://avatar.csdn.net/A/D/0/3_jackpk.jpg" onclick="<span style="background-color: rgb(255, 255, 102);">return false;</span>"/> --> <!-- 下面写法,IE8、firefox 33.1 均提交【1】次:/aJoke.do --> <input type="submit" value="input_submit"/> </form> </body> </html>





html 标签: image也能提交form!!!

标签:pop   结果   ack   注意   set   function   title   space   表单   

原文地址:http://www.cnblogs.com/wzzkaifa/p/7019533.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!