2013年1月1日 星期二

JQuery外掛-Google Search

範例:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head>

<title>GoogleSearch</title>

<meta http-equiv="imagetoolbar" content="no" />

<meta http-equiv="Content-Language" content="de" />

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />

<link rel="stylesheet" type="text/css" href="css/nurtext.css" media="all" />

<link rel="stylesheet" type="text/css" href="css/gSearch.css" media="all" />

<link rel="stylesheet" type="text/css" href="css/print.css" media="print" />

<!--<script type="text/javascript" src="http://google.com/jsapi?key=ABQIAAAAfN6uj201k4Vercw6FDN-ihT2yXp_ZAY8_ufC3CFXhHIE1NvwkxTmu0D78Qv7-23u5lWPh9d1xNFNPQ"></script>-->

<script type="text/javascript">         google.load("jquery", "1");</script>

<script type="text/javascript">         google.load("search", "1");</script>

<script type="text/javascript" src="js/jquery.gSearch-1.0-min.js"></script>

<script type="text/javascript">

function showMsg(e) {

var SearchTxt = $("#txtSearch").val();

if (typeof SearchTxt == 'undefined')

return;

$("#search-results").gSearch({

search_text: '計畫 模具 '+SearchTxt,

site: 'www.etop.org.tw',

count: 8,

pagination: true

});

}

$(document).ready(function(e){

$('#btnSearch').click(showMsg);

});

</script>

</head>

<body id="top">

<div id="center">

<div id="content">

<input type="text" id="txtSearch" />

<input type="button" id="btnSearch" value='Search' />

<div id="search-results"></div>

</div>

</div>

</body>

</html>

  • 引用jquery:jquery.gSearch-1.0-min.js
  • 範例:站內搜尋
    • search_text:搜尋文字
    • site:搜尋的網站
    • count:數目
    • pagination:是否分頁

沒有留言:

張貼留言