全站搜索:
<div class="head_right">
<input type="text" class="search_text" id="search_text"/>
<a id="search_bt" class="search_bt" onclick="return doSearch(this);"></a>
</div>
<script>
//搜索操作
function doSearch(obj) {
var keyWord = $(‘#search_text‘).val().replace(/ /g, ‘‘);
if (keyWord.length < 3) {
alert(‘Please enter at least 3 keywords.‘);
return false;
}
var href = ‘en_newsletter.aspx?KeyWord=‘ + encodeURI(keyWord);
$(obj).attr(‘href‘, href);
return true;
}
//使用ENTER键代替button
$(function () {
$(‘.head_right‘).keydown(function (e) {
var curKey = e.which;
if (curKey == 13) {
if ($(‘.search_bt‘).length > 0)
$(‘.search_bt‘).get(0).click();
return false;
}
});
});
</script>