「Google/カスタム検索」の版間の差分
提供: 初心者エンジニアの簡易メモ
(→pagerのスタイル) |
(→pagerのスタイル) |
||
| 行23: | 行23: | ||
http://example.com/?q=hogehoge | http://example.com/?q=hogehoge | ||
| − | == | + | ==pagerのclass属性定義== |
| + | 以下のようになってるので独自にcssを当てれば良い。 | ||
<<nowiki/>div class="gsc-cursor"> | <<nowiki/>div class="gsc-cursor"> | ||
<<nowiki/>div class="gsc-cursor-page" tabindex="0">1</div> | <<nowiki/>div class="gsc-cursor-page" tabindex="0">1</div> | ||
<<nowiki/>div class="gsc-cursor-page gsc-cursor-current-page" tabindex="0">2</div> | <<nowiki/>div class="gsc-cursor-page gsc-cursor-current-page" tabindex="0">2</div> | ||
<<nowiki/>/div> | <<nowiki/>/div> | ||
2015年10月4日 (日) 07:06時点における版
Google検索のサイト
https://cse.google.co.jp/cse/all
urlパラメータを渡し結果のみをGoogle検索で表示する方法
検索エンジン選択/デザイン/レイアウト/結果のみを選択/コードを取得
結果のみ表示するコードを貼る
<script>
(function() {
var cx = '003685xxxxxxxxxxxxxx:wepxuxxxxx';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
'//cse.google.com/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:searchresults-only>Loading...</gcse:searchresults-only>
こんな感じでキーワードパラメータを渡す。 http://example.com/?q=hogehoge
pagerのclass属性定義
以下のようになってるので独自にcssを当てれば良い。
<div class="gsc-cursor"> <div class="gsc-cursor-page" tabindex="0">1</div> <div class="gsc-cursor-page gsc-cursor-current-page" tabindex="0">2</div> </div>
