form表单中使button点击后不起作用的方法和原理
2012-10-17 18:35
274 查看
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>event</title>
</head>
<body>
<div class="admin_right_shell">
<p class="toptitle">资源公告管理</p>
<form id="mainForm" name="mainForm" action="/resrepo-webapp/admin/notice.action" method="post">
<div class="auditor_option_box">
<button class="noticebutton" id="publish">发布</button>
<button class="noticebutton" id="noticeadd"
onclick="window.location.href = '/resrepo-webapp/admin/notice!input.action'; if(event.preventDefault){event.preventDefault();event.stopPropagation();}else{return false;};event.cancelBubble = true;">新增</button>
<!--之所以button类型的按钮点击后form提交,其实是事件冒泡,只要阻止冒泡就可以了。网上寻很久找不到原因,参照jquery.handle方法的事件处理后才明白,吃惊老外的水平 -->
</div>
</form>
</div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>event</title>
</head>
<body>
<div class="admin_right_shell">
<p class="toptitle">资源公告管理</p>
<form id="mainForm" name="mainForm" action="/resrepo-webapp/admin/notice.action" method="post">
<div class="auditor_option_box">
<button class="noticebutton" id="publish">发布</button>
<button class="noticebutton" id="noticeadd"
onclick="window.location.href = '/resrepo-webapp/admin/notice!input.action'; if(event.preventDefault){event.preventDefault();event.stopPropagation();}else{return false;};event.cancelBubble = true;">新增</button>
<!--之所以button类型的按钮点击后form提交,其实是事件冒泡,只要阻止冒泡就可以了。网上寻很久找不到原因,参照jquery.handle方法的事件处理后才明白,吃惊老外的水平 -->
</div>
</form>
</div>
</body>
</html>
相关文章推荐
- JavaScript在form表单中使用button按钮实现submit提交方法
- jquery下的提交,点击按钮没反应,post方法不执行 JSON方式在FORM表单下不起作用
- 解决layui中的form表单与button的点击事件冲突问题
- form表单button自动提交表单处理方法
- button等form表单点击出现边框解
- button在Firefox下点击提交表单(form)的问题
- form表单底下的button按钮点击自动提交恶心问题的解决
- button放在form表单导致点击按钮触发的ajax报错问题
- form中button未设置type值时点击后提交表单
- 页面点击button自动提交form表单的解决办法
- 点击form表单中的button会触发页面刷新
- javascript在form表单中使用button按钮实现submit提交方法
- YII2.0 Activeform表单组件的使用方法
- php 解决和避免form表单重复提交的方法
- 表单验证之validform.js使用方法
- php 解决和避免form表单重复提交的方法
- android的button点击变换颜色的方法
- 使用ajax方法实现form表单的提交
- 【Django】Django—Form两种解决表单数据无法动态刷新的方法
- Android点击AlertDialog的button不退出对话框的方法