急求高手指点 JS正则提取URL中关键字
xldgo 2010-10-27 09:25:08 想从网址: http://127.0.0.1/plus/search.php?kwtype=0&q=%B9%C9%C6%B1 提取出q=后面的关健字,然后,改动一下,下面代码红色的部分,使整代码能正常工作
这段代码是GOOGLE自定义搜索中的一部分,我就是希望当出现上面这种链接,后面带关键字的时候,下面代码能自动识别出URL中的关键字,并自动搜索输出结果,请高手指点一下,谢谢
<script type="text/javascript">
google.load('search', '1', {language : 'zh-CN'});
google.setOnLoadCallback(function(){
var customSearchControl = new google.search.CustomSearchControl('009527755525159401988:63iuuetccag');
customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
customSearchControl.draw('cse');
var match = location.search.match(/q=([^&]*)(&|$)/);
if(match && match[1]){
var search = decodeURIComponent(match[1]);
customSearchControl.execute(search); }
});
</script>