DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> 關於JavaScript >> form表單中去掉默認的enter鍵提交並綁定js方法實現代碼
form表單中去掉默認的enter鍵提交並綁定js方法實現代碼
編輯:關於JavaScript     
復制代碼 代碼如下:
<form id="index-search_form" method="post" >
<input type="text" id="s" value=""
onkeydown="javascript:if(event.keyCode==13) return false;"
onkeyup="javascript:if(event.keyCode==13) dosearch();"
class="swap_value" />
<img onclick="dosearch();"
src="${ctx }/MINIUI/scripts/miniui/themes/default/images/img/btn_search_box2.gif"
width="36" height="26" id="go" alt="Search" title="Search" />
</form>

復制代碼 代碼如下:
function dosearch(){
var keywords=$("#s").val();
keywords=encodeURI(keywords);
keywords=encodeURI(keywords);
// window.open("${ctx}/DispatchAction.do?serviceName=SearchWeb&efFormEname=FS01&methodName=query&i-0-page=0&i-0-keywords="+keywords+"&i-0-moduleId=bmoa_badc");
location.href="${ctx}/DispatchAction.do?serviceName=SearchWeb&efFormEname=FS01&methodName=query&i-0-page=0&i-0-keywords="+keywords;
}
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved