プレビュー ウィザード
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
プレビュー ウィザードは、サイトにプレビューをすばやく簡単に統合できるように設計されています。コードを生成してページに貼り付けるだけで、書籍ビューアを埋め込んだり、ブック検索にリンクしたり、プレビューの「ポップアップ」ウィンドウをサイトに追加したりできます。簡単な JavaScript 関数を使用してこのコードをカスタマイズすることもできます。
プレビュー ウィザードは、Google の Dynamic Links API と埋め込みビューア API 上に構築された、シンプルな便利なライブラリです。高度な統合が必要な場合は、基盤となる API を直接使用することを検討してください。
プレビュー コードを生成する
生成されたプレビューの例
以下の例は、プレビュー ウィザードを使用して生成されました。
コードをカスタマイズする
上記のウィザードを使用するだけでなく、単純な JavaScript の「ヘルパー」関数を直接呼び出すこともできます。そのためには、まずプレビュー ウィザード ライブラリを読み込みます。たとえば、次のタグをページの <head>
セクションに追加します。
<script type="text/javascript" src="https://books.google.com/books/previewlib.js"></script>
プレビュー ライブラリを読み込んだら、ドキュメントの <body>
内の <script>
タグ内から、次のいずれかの関数を呼び出すことができます。たとえば、「Google プレビュー」ボタンを挿入する場合は、ページ内のボタンの希望する位置の <script>
要素にコードを配置します。
GBS_setLanguage
GBS_setLanguage(languageCode)
この関数の呼び出し後に追加されるボタンやテキストの言語を変更します。これには、[Google プレビュー] ボタンの言語、埋め込みプレビューのインターフェース言語などが含まれます。
パラメータ:
string languageCode
- 目的の RFC 3066 言語コード(デフォルトは英語の場合は「en」)。現在サポートされている言語コードは、hy、bg、ca、zh-CN、zh-TW、hr、cs、da、nl、en、fil、fi、fr、de、el、hi、hu、is、id、in、it、ja、ko、lv、lt、no、pl、pt-BR、pt-
GBS_setViewerOptions
GBS_setViewerOptions(optionObj)
パラメータ:
Object optionsObj
- Embedded Viewer API の DefaultViewer コンストラクタに渡される Key-Value ペアのセット。通常、これは高度なカスタマイズに使用されます。
GBS_setCobrandName
GBS_setCobrandName(cobrandName)
この関数は、パートナー プログラムに参加しているニュース メディアが使用するためのものです。ブック検索にプレビュー リンクを挿入するときに使用する提携ブランド検索サイトを設定します。ボタンを挿入する前にこの関数を呼び出すと、ブック検索のプレビューの上にパートナーのロゴが表示されます。
GBS_insertEmbeddedViewer
GBS_insertEmbeddedViewer(identifier, opt_width, opt_height)
この関数が呼び出される場所に埋め込みの書籍プレビューを挿入します。プレビューが利用できない場合、ビューアは表示されません。
パラメータ:
Number opt_width
- ビューアに必要な幅(ピクセル単位)。
Number opt_height
- ビューアに必要な高さ(ピクセル単位)。
GBS_insertPreviewButtonPopup(identifiers)
パラメータ:
string, Array identifier
- プレビュー URL、または書籍 ID(ISBN、OCLC、LCCN 番号など)。Dynamic Links リクエストの形式をご覧ください。書籍の代替 ID がわかっている場合は、これらの ID の配列を渡すことができます。いずれかの ID でプレビューが利用可能な場合、ボタンが表示されます。
GBS_insertPreviewButtonLink(identifiers, opt_options)
書籍のプレビューが可能な場合、この関数は書籍のプレビュー ページにリンクするだけの [Google プレビュー] ボタンを書き出します。デフォルトでは、Google ブックスのプレビューにリンクされますが、次のこともできます。
- サイトの URL へのリンク(埋め込みビューアが含まれる必要があります)これを行うには、オプションの
alternativeUrl
オプションを渡します。
- この関数の前に GBS_setCobrandName が呼び出された場合、ブランド提携版の書籍プレビュー ページにリンクします。
ユーザーがプレビューを使用できない場合、ページにボタンは描画されません。
パラメータ:
string, Array identifier
- プレビュー URL、または書籍 ID(ISBN、OCLC、LCCN 番号など)。Dynamic Links リクエストの形式をご覧ください。書籍の代替 ID がわかっている場合は、これらの ID の配列を渡すことができます。いずれかの ID でプレビューが利用可能な場合、ボタンが表示されます。
Object opt_options
- 省略可 - ボタンの動作を構成するために使用される名前 - 値マップ。現在サポートされているオプションは alternativeUrl
の 1 つです。たとえば、Google プレビュー ボタンをサイトのカスタム プレビュー ページにリンクするには、GBS_insertPreviewButtonLink
に次の 2 番目の引数として渡します。
{ 'alternativeUrl' : 'http://yoursite.com/your-preview-page' }
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2024-06-28 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2024-06-28 UTC。"],[],[],null,["The Preview Wizard is designed to let you quickly, easily, and reliably integrate previews with your site. You can embed a book viewer, link to Book Search, or even add a preview \"popup\" window to your site---all you need to do is [generate the code](#generateCode) and paste it onto your page. You can also [customize this code](#customizeYourCode) using some simple JavaScript functions.\n\nThe Preview Wizard is a simple convenience library we built on top of our [Dynamic Links](/books/docs/dynamic-links) and [Embedded Viewer](/books/docs/viewer/developers_guide) APIs. If you're an advanced developer looking for customized integration, consider\nusing the underlying APIs directly.\n\nGenerate your preview code \n\nEnter book identifiers \nTell us all the ISBNs or other identifiers you know of for this book. If we can find a preview associated with any of these numbers, we can make it available to your site's users:\n\n|--------------------------------------|---|\n| ISBN OCLC number LCCN Book Search ID | |\n| ISBN OCLC number LCCN Book Search ID | |\n| ISBN OCLC number LCCN Book Search ID | |\n\n[Enter more identifiers...](about:invalid#zGoSafez)\n\nChoose how to show the book preview \n\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| If a preview is available for this book, what should the user see on your page? |---|------------------------------------------------------------------------| | | An embedded book viewer. Viewer size: pixels wide, pixels high | | | A button that opens a floating book viewer. | | | A button that links to the book's preview page on Book Search. | | | A button that goes to a custom preview page on your site. Preview URL: | If no preview can be found for the specified book(s), the preview or button will be automatically disabled and nothing will appear. | |\n\nSelect your language \nChinese (Simplified) Chinese (Traditional) Dutch English French German Italian Japanese Portuguese (Brazilian) Russian Spanish\n\nGenerate code for your web page \n\nExamples of generated previews\n\nThe following examples were generated using the Preview Wizard.\n\n- [previewwizard-embed](/books/examples/previewwizard-embed): Embeds a book viewer on the page.\n- [previewwizard-popup](/books/examples/previewwizard-popup): Adds a button that can be clicked to open a floating preview over the page.\n- [previewwizard-linktogbs](/books/examples/previewwizard-linktogbs): Inserts a button that links to the preview on the Book Search site.\n- [previewwizard-customurl](/books/examples/previewwizard-customurl): Shows a button that goes to a specific URL.\n\nCustomize your code\n\nIn addition to using the wizard above, you can call some simple JavaScript \"helper\" functions directly. To do this, you should first load the Preview Wizard library. One way to do this is by adding the following tag to the `\u003chead\u003e` section of your page: \n\n```\n\u003cscript type=\"text/javascript\" src=\"https://books.google.com/books/previewlib.js\"\u003e\u003c/script\u003e\n```\n\nHaving loaded the preview library, you can then call any of the following functions from within `\u003cscript\u003e` tags inside your document's `\u003cbody\u003e`. For example, if you'd like to insert the \"Google Preview\" button, you'd put the code to do so in a `<script\u003e` element at the button's desired position within the page.\n\nGBS_setLanguage \n\n```\nGBS_setLanguage(languageCode)\n```\n\nChanges the language of any buttons or text added after this function is called. This includes the language of the \"Google Preview\" button, the interface language of the embedded preview, and so on.\n\n\u003c!-- --\u003e\n\n**Parameters:** *string*` languageCode ` - The desired RFC 3066 language code (default is 'en' for English). Currently supported language codes include hy, bg, ca, zh-CN, zh-TW, hr, cs, da, nl, en, fil, fi, fr, de, el, hi, hu, is, id, in, it, ja, ko, lv, lt, no, pl, pt-BR, pt-PT, ro, ru, sr, sk, sl, es, sv, th, tr, uk, and vi.\n\nGBS_setViewerOptions \n\n```\nGBS_setViewerOptions(optionObj)\n```\n\n**Parameters:** *Object*` optionsObj ` - A set of key-value pairs passed to the Embedded Viewer API's [DefaultViewer constructor](/books/docs/viewer/reference#google.books.DefaultViewer). Typically, this is used for advanced customizations.\n\nGBS_setCobrandName \n\n```\nGBS_setCobrandName(cobrandName)\n```\n\nIntended for use by publishers in the [Partner Program](https://books.google.com/partner), this function sets the [Co-Branded Search](https://books.google.com/support/partner/bin/answer.py?hl=en&answer=65113) site to be used when inserting any preview links to Book Search. Calling this function before inserting a button ensures that users see the partner's logo above the Book Search previews.\n\n\u003c!-- --\u003e\n\n**Parameters:** *string*` cobrandName ` - The cobrand name to be added to any Book Search URLs. This is typically what comes after `/p/` in existing Co-Branded Search preview URLs.\n- For example, setting the value to `sup` will send the user to links like \n `https://books.google.com/books/p/sup?id=Q8ysL64pM54C&printsec=frontcover` \n rather than the default \n `https://books.google.com/books?id=Q8ysL64pM54C&printsec=frontcover`\n\nGBS_insertEmbeddedViewer \n\n```\nGBS_insertEmbeddedViewer(identifier, opt_width, opt_height)\n```\n\nInserts an embedded book preview wherever this function is called. If the preview is unavailable, no viewer is shown.\n\n\u003c!-- --\u003e\n\n**Parameters:** *string*` identifier ` - A preview URL or book identifier such as an ISBN, OCLC, or LCCN number. See [Dynamic Links request format](/books/docs/dynamic-links#requestFormat).\n\u003c!-- --\u003e\n\n*Number*` opt_width ` - The desired width of the viewer, in pixels.\n\u003c!-- --\u003e\n\n*Number*` opt_height ` - The desired height of the viewer, in pixels.\n\nGBS_insertPreviewButtonPopup \n\n```\nGBS_insertPreviewButtonPopup(identifiers)\n```\n\nIf the book preview is available, this function writes out a \"Google Preview\" button. Clicking this button opens a \"floating preview window\" right on top of your page. If no preview is available, the button is not drawn.\n- More sophisticated developers may be interested in the [Embedded Viewer API](/books/docs/viewer/developers_guide), which this function uses internally.\n\n\u003c!-- --\u003e\n\n**Parameters:** *string, Array*` identifier ` - A preview URL or book identifier such as an ISBN, OCLC, or LCCN number. See [Dynamic Links request format](/books/docs/dynamic-links#requestFormat). If you know of several alternative identifiers for the book, you can pass an array of these identifiers, and the button will appear if a preview is available for any one of them.\n\nGBS_insertPreviewButtonLink \n\n```\nGBS_insertPreviewButtonLink(identifiers, opt_options)\n```\n\nIf the book preview is available, this function writes out a \"Google Preview\" button that simply links off to a preview page for the book. By default, this links to the preview on Google Books, but you can also:\n- link to a URL on your site (which should, in turn contain an embedded viewer). You can do this by passing an optional `alternativeUrl` option.\n- link to a Co-Branded version of the book preview page, if [GBS_setCobrandName](#GBS_setCobrandName) is called before this function.\nIf no preview is available to the user, no button is drawn onto the page.\n\n\u003c!-- --\u003e\n\n**Parameters:** *string, Array*` identifier ` - A preview URL or book identifier such as an ISBN, OCLC, or LCCN number. See [Dynamic Links request format](/books/docs/dynamic-links#requestFormat). If you know of several alternative identifiers for the book, you can pass an array of these identifiers, and the button will appear if a preview is available for any one of them.\n\u003c!-- --\u003e\n\n*Object*` opt_options ` - *optional* - A name-value map used to configure the behavior of the button. Currently one option is supported: `alternativeUrl`. For example, to have the Google Preview button link to a custom preview page on your site, simply pass the following as a second argument to `GBS_insertPreviewButtonLink`: \n` { 'alternativeUrl' : 'http://yoursite.com/your-preview-page' } `"]]