Anteprima guidata
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
La procedura guidata di anteprima è progettata per consentirti di integrare le anteprime nel tuo sito in modo rapido, semplice e affidabile. Puoi incorporare un visualizzatore di libri, inserire un link a Ricerca Libri o persino aggiungere una finestra popup di anteprima al tuo sito: devi solo generare il codice e incollarlo nella tua pagina. Puoi anche personalizzare questo codice utilizzando alcune semplici funzioni JavaScript.
La procedura guidata di anteprima è una semplice e pratica libreria che abbiamo costruito sfruttando le nostre API Dynamic Links e Embedded Viewer. Se sei uno sviluppatore avanzato e alla ricerca di un'integrazione personalizzata, valuta
la possibilità di utilizzare direttamente le API sottostanti.
Genera il codice di anteprima
Esempi di anteprime generate
I seguenti esempi sono stati generati utilizzando la procedura guidata di anteprima.
Personalizza il codice
Oltre a utilizzare la procedura guidata descritta sopra, puoi chiamare direttamente alcune semplici funzioni "helper" di JavaScript. Per farlo, devi prima caricare la libreria della procedura guidata di anteprima. Un modo per farlo è aggiungere il seguente tag alla sezione <head>
della pagina:
<script type="text/javascript" src="https://books.google.com/books/previewlib.js"></script>
Dopo aver caricato la libreria di anteprima, puoi chiamare una delle seguenti funzioni dai tag <script>
all'interno dell'elemento <body>
del documento. Ad esempio, per inserire il pulsante "Anteprima Google", devi inserire il codice per farlo in un elemento <script>
nella posizione desiderata del pulsante all'interno della pagina.
GBS_setLanguage
GBS_setLanguage(languageCode)
Modifica la lingua di eventuali pulsanti o testo aggiunti dopo la chiamata di questa funzione. tra cui la lingua del pulsante "Anteprima Google", la lingua dell'interfaccia dell'anteprima incorporata e così via.
Parametri:
string languageCode
. Il codice lingua RFC 3066 desiderato (il valore predefinito è "en" per l'inglese). I codici lingua attualmente supportati sono 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, ru, pt-BR, pt-sk, ros, tr, s
GBS_setViewerOptions
GBS_setViewerOptions(optionObj)
Parametri:
Object optionsObj
: un insieme di coppie chiave-valore passate al costruttore DefaultViewer dell'API Embedded Viewer. In genere, viene utilizzato per personalizzazioni avanzate.
GBS_setCobrandName
GBS_setCobrandName(cobrandName)
Questa funzione, destinata agli editori che aderiscono al Programma partner, consente di impostare l'utilizzo del sito Ricerca co-branded durante l'inserimento di eventuali link di anteprima nella Ricerca Libri. Chiamare questa funzione prima di inserire un pulsante garantisce che gli utenti vedano il logo del partner sopra le anteprime di Google Ricerca Libri.
Parametri:
string cobrandName
. Il nome del co-branding da aggiungere a qualsiasi URL di Google Ricerca Libri. In genere si tratta di quello che segue /p/
negli URL di anteprima della ricerca co-branding esistenti.
Ad esempio, se il valore viene impostato su sup
, l'utente verrà indirizzato a link come
https://books.google.com/books/p/sup?id=Q8ysL64pM54C&printsec=frontcover
anziché il valore predefinito
https://books.google.com/books?id=Q8ysL64pM54C&printsec=frontcover
GBS_insertEmbeddedViewer
GBS_insertEmbeddedViewer(identifier, opt_width, opt_height)
Inserisce un'anteprima del libro incorporata dove viene chiamata questa funzione. Se l'anteprima non è disponibile, non viene mostrato alcun visualizzatore.
Parametri:
Number opt_width
: la larghezza desiderata del visualizzatore, in pixel.
Number opt_height
: l'altezza desiderata del visualizzatore, in pixel.
GBS_insertPreviewButtonPopup(identifiers)
Se l'anteprima del libro è disponibile, questa funzione crea un pulsante "Anteprima Google". Se fai clic su questo pulsante, si apre una "finestra di anteprima mobile" nella parte superiore della pagina. Se non è disponibile alcuna anteprima, il pulsante non è disegnato.
Gli sviluppatori più sofisticati possono considerare l'API Embedded Viewer, che questa funzione utilizza internamente.
Parametri:
string, Array identifier
. Un URL di anteprima o un identificatore del libro, ad esempio un numero ISBN, OCLC o LCCN. Consulta Formato della richiesta di Dynamic Links. Se conosci diversi identificatori alternativi per il libro, puoi trasmettere un array di questi identificatori e il pulsante verrà visualizzato se è disponibile un'anteprima per uno qualsiasi di questi identificatori.
GBS_insertPreviewButtonLink(identifiers, opt_options)
Se l'anteprima del libro è disponibile, questa funzione crea un pulsante "Anteprima Google" che rimanda a una pagina di anteprima del libro. Per impostazione predefinita, questo link rimanda all'anteprima su Google Libri, ma puoi anche:
- Rimandano a un URL sul tuo sito (che a sua volta dovrebbe contenere un visualizzatore incorporato). Puoi farlo passando un'opzione facoltativa
alternativeUrl
.
- Creare un link a una versione in co-branding della pagina di anteprima del libro, se GBS_setCobrandName viene chiamato prima di questa funzione.
Se non è disponibile nessuna anteprima per l'utente, nella pagina non viene visualizzato alcun pulsante.
Parametri:
string, Array identifier
. Un URL di anteprima o un identificatore del libro, ad esempio un numero ISBN, OCLC o LCCN. Consulta Formato della richiesta di Dynamic Links. Se conosci diversi identificatori alternativi per il libro, puoi trasmettere un array di questi identificatori e il pulsante verrà visualizzato se è disponibile un'anteprima per uno qualsiasi di questi identificatori.
Object opt_options
(facoltativo): una mappa nome-valore utilizzata per configurare il comportamento del pulsante. Al momento è supportata un'opzione: alternativeUrl
. Ad esempio, per fare in modo che il pulsante Anteprima Google rimandi a una pagina di anteprima personalizzata sul tuo sito, trasmetti semplicemente il seguente argomento come secondo argomento a GBS_insertPreviewButtonLink
:
{ 'alternativeUrl' : 'http://yoursite.com/your-preview-page' }
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2024-06-28 UTC.
[null,null,["Ultimo aggiornamento 2024-06-28 UTC."],[],[],null,["# Preview Wizard\n\nThe 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--------------------------\n\n#### Enter book identifiers\n\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\n#### Choose 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\n#### Select your language\n\nChinese (Simplified) Chinese (Traditional) Dutch English French German Italian Japanese Portuguese (Brazilian) Russian Spanish\n\n#### Generate code for your web page\n\nExamples of generated previews\n------------------------------\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-------------------\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\n### GBS_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\n### GBS_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\n### GBS_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\n### GBS_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\n### GBS_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\n### GBS_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' } `"]]