検索結果のカスタマイズ
検索ボックスをカスタマイズするのと同様に、検索結果要素にオプションを追加できます。
たとえば、検索エンジンをウェブ検索結果ベースから変更する場合、
画像ベースにするには、defaultToImageSearch
属性を利用できます。
まず、検索エンジンのコントロール パネルで画像検索を有効にする必要があります。[設定] セクションの [基本] タブで、[画像検索] オプションをクリックして「オン」にします。なります。その後、ウェブサイトの <div class="gcse-searchresults"></div>
要素に defaultToImageSearch
属性を追加します。
<!-- ご自身のプログラム可能検索エンジン ID をここに挿入 -->
<script async src="https://cse.google.com/cse.js?cx=017643444788069204610:4gvhea_mvga"></script>
<!-- 属性値を「true」に変更してみてくださいまたは「false」-->
<div class="gcse-searchbox"></div>
<div class="gcse-searchresults" data-defaultToImageSearch="true"></div>
これで、何かを検索するとデフォルトで [画像検索] タブが表示されるようになりました。
他にも多くのオプションがあります。その他の検索結果のカスタマイズ オプションについては、Programmable Search Element Control API のセクションをご覧ください。
次のステップ
次のステップに進みます。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2024-08-22 UTC。
[null,null,["最終更新日 2024-08-22 UTC。"],[[["The search results element can be customized with additional options, such as switching to image-based results using the `defaultToImageSearch` attribute."],["To enable image search, you need to activate it in the Control Panel for your search engine and then add the `defaultToImageSearch` attribute to the search results div element."],["The `defaultToImageSearch` attribute, when set to \"true\", makes the image search tab the default view for search results."],["Further customization options for search results can be found in the Programmable Search Element Control API documentation."]]],[]]