您的位置:首页 > 其它

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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: