- google custom search can't work
- <!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" lang="zh-hans" xml:lang="zh-hans">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>test</title>
- </head>
- <body>
- <div class="fr_search">
- <form action="cse.php" accept-charset="UTF-8" method="post" id="search-theme-form">
- <input type="text" maxlength="128" name="search_theme_form" id="edit-search-theme-form-1" size="15" value="" class="form-text" />
- <input type="image" name="submit" id="edit-submit" class="form-submit" src="images/search_btn_top.gif" /></div>
- </form>
- </div>
- </body>
- </html>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title>test search</title>
- </head>
- <body>
- <script src="http://www.google.com/jsapi" type="text/javascript"></script>
- <script type="text/javascript">
- google.load('search', '1', {language : 'en'});
- google.setOnLoadCallback(function() {
- var customSearchControl = new google.search.CustomSearchControl ('011247711644571852159:xe2ytn1hwsa');
- customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
- customSearchControl.draw('cse');
- }, true);
- </script>
- <link rel="stylesheet" href="http://www.google.com/cse/style/look/default.css" type="text/css" />
- <?php echo 'test'; ?>
- </body>
- </html>
- <div id="cse">Loading…</div>
- <script src="http://www.google.com/jsapi"></script>
- <script>
- // Extract user's query from the URL
- function getQuery() {
- var url = '' + window.location;
- var queryStart = url.indexOf('?') + 1;
- if (queryStart > 0) {
- var parts = url.substr(queryStart).split('&');
- for (var i = 0; i < parts.length; i++) {
- if (parts[i].length > 2 && parts[i].substr(0, 2) == 'q=') {
- return decodeURIComponent(parts[i].split('=')[1].replace(/+/g, ' '));
- }
- }
- }
- return '';
- }
- google.load('search', '1', {language:'en' });
- google.setOnLoadCallback(function() {
- var cseControl = new google.search.CustomSearchControl('ID_GOES_HERE');
- cseControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
- cseControl.draw('cse');
- // Execute a query based on the query string
- cseControl.execute(getQuery());
- }, true);
- </script>
- <form action="cse.php" method="get">
- <input name="q"> <input type="submit">
- </form>