您的位置:首页 > 编程语言

经过测试通过csdn的非form搜索代码(SearchMash版)(Copyright © 2007 SearchMash)

2007-03-24 20:52 375 查看
经过测试通过csdn的非form搜索代码(SearchMash版)(Copyright © 2007 SearchMash)

这个算是2.0吧,o(∩_∩)o...哈哈,区别与先前写的搜索代码。

http://blog.csdn.net/clin003/archive/2006/10/02/1316885.aspx
终于在公告栏里加进啦Google自定义搜索引擎(附代码,和参考代码,原代码)

其实这个是利用啦SearchMash在处理提交数据时把“?”后边的数据忽略啦(只是过滤啦“用户输入关键字”外的表单属性信息)。所以不用考虑实际表单提交的数据被附加csdn的一些表单属性等信息。
<div style="text-align: left;">
<!-- edit by clin003 at 200703242035 转载请注明出处,这次修改是考虑啦csdn's blog 有个form,但源代码中利用form提交信息!!,
造成正常从searchmash截取的代码不能正常工作。

上次的搜索代码使用的是google的广告+搜索,这次的完全是google的searchmash搜索结果,
本次修改是对本blog做搜索
若你想拿去放到自己blog,并且搜自己的blog可以把代码中的blog.csdn.net/clin003替换为你的blog地址 -->
<script language="javascript">
var idleTimer;

function encode(param) {
  return encodeURIComponent(param).
      replace(/%20/g, "+").
      replace(/%3A/g, ":");
}

function handleKey() {
  document.getElementById("tip").innerHTML = (this.value == "")
      ? "输入关键字准备开始搜索"
      : "回车或点上边的按钮得到搜索结果";
  if (idleTimer) {
    window.clearTimeout(idleTimer);
  }
  idleTimer = window.setTimeout(handleIdle, 30000);
}

function search(q) {<!--这个搜索函数就不用啦o(∩_∩)o...哈哈 -->
  q = q.replace(/^/s+/, '').replace(//s+$/, '');
  document.location = "http://www.searchmash.com/search/site:blog.csdn.net/clin003%20" + encode(q);
 window.location = "http://www.searchmash.com/search/site:blog.csdn.net/clin003%20" + encode(q);
Form1.onsubmit="javascript:return search(this.query.value)";

return false;
}

function handleIdle() {
  var qb = document.getElementsByName("query")[0];
  if (qb.value == "") {
    document.getElementById("tip").innerHTML =
      "不知道要搜什么么 " +
      "<a href='http://www.searchmash.com/explore/explore'>看看流行榜</a>...";
  }
}

function handleLoad() {
  var qb = document.getElementsByName("query")[0];
  qb.focus();
  qb.onkeyup = handleKey;
  qb.onkeyup();
}

 

function on_search_click(q){
  q = q.replace(/^/s+/, '').replace(//s+$/, '');<!--这主要是把输入做过滤作用 -->

 Form1.action ="http://www.searchmash.com/search/site:blog.csdn.net/clin003%20" + encode(q);
 Form1.onsubmit="javascript:return search(query.value)" ;
Form1.target = "_blank";
 Form1.method = "get";

}

</script>

<body onload="handleLoad()">
<div id="content">

<input type="submit"  value="SearchMash" onclick="javascript:on_search_click(query.value)"></input>
<br><input type="search" maxlength="2048" id="query"
    name="query" placeholder="Search" onKeyDown="javascript:on_search_click(query.value)">

<div class="tip">↑ <span id="tip"></span></div>

</div>

 

</body>

<div style="text-align: left;">
<!-- edit by clin003 at 200703242035 转载请注明出处,这次修改是考虑啦csdn's blog 有个form,但源代码中利用form提交信息!!,
造成正常从searchmash截取的代码不能正常工作。

上次的搜索代码使用的是google的广告+搜索,这次的完全是google的searchmash搜索结果,
本次修改是对本blog做搜索
若你想拿去放到自己blog,并且搜自己的blog可以把代码中的blog.csdn.net/clin003替换为你的blog地址 -->

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐