读书人

html页面数据提交有关问题

发布时间: 2012-05-16 23:40:10 作者: rapoo

html页面数据提交问题

HTML code
   <input type="submit" value=" 保存" onclick="javascript:__doPostBack('ctl00$MainContent$toolbarPersonEdit','Save$')" id="MainContent_Save" class="saveButtonIco" />


JScript code
   <script type="text/javascript">//<![CDATA[var theForm = document.forms['form1'];if (!theForm) {    theForm = document.form1;}function __doPostBack(eventTarget, eventArgument) {    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {        theForm.__EVENTTARGET.value = eventTarget;        theForm.__EVENTARGUMENT.value = eventArgument;        theForm.submit();    }}//]]></script>


ie8提交两次,ie9,火狐,谷歌提交一次。
我知道type="submit" 会提交表单,__doPostBack也会提交表单,那为什么偏偏只有ie8提交了两次??

[解决办法]
<input type="submit" value=" 保存"
改成
<input type="button" value=" 保存"

否则,既执行onlick,又执行submit。浏览器存在bug,不建议使用 <input type="submit"又写onlick

读书人网 >asp.net

热点推荐