參考資料
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
內嵌式檢視器 API 包含一個類別:DefaultViewer。如需 API 使用簡介,請參閱開發人員指南。
建構函式摘要
google.books.DefaultViewer(div, opt_options)
- Google 圖書搜尋中書籍的內嵌檢視器。
方法摘要
string
getPageNumber()
- 傳回目前在可視區域顯示的頁面頁碼。
string
getPageId()
- 傳回目前在可視區域中顯示的網頁專屬 ID。
boolean
goToPage(pageNumber)
- 如果網頁已存在且已變成,會傳回 true。
boolean
goToPageId(pageId)
- 如果網頁已存在且已變成,會傳回 true。
boolean
isLoaded()
- 指出觀眾是否已成功使用指定書籍進行初始化。
highlight(opt_string)
- 醒目顯示可視區域中的字詞。
load(identifiers, opt_notFoundCallback, opt_successCallback)
- 在可視區域中載入書籍。
nextPage()
- 前往書籍中的下一頁。
previousPage()
- 前往書籍的上一頁。
resize()
- 根據容器 div 的大小調整檢視器的大小。
zoomIn()
- 將檢視器放大。
zoomOut()
- 將檢視器縮小。
建構函式詳細資料
google.books.DefaultViewer
google.books.DefaultViewer(div, opt_options)
在 Google 圖書搜尋中,用於嵌入書籍的檢視器。
參數:
Element div
- 用於繪製 viewport 的 div。
Object opt_options
- 選項的鍵/值對應,用於傳遞給檢視者。
方法詳細資料
getPageNumber
string getPageNumber()
getPageId
string getPageId()
goToPage
boolean goToPage(pageNumber)
參數:
string, number pageNumber
- 要轉到的頁面編號。
goToPageId
boolean goToPageId(pageId)
參數:
string pageId
- 要轉到的網頁專屬 ID。
isLoaded
boolean isLoaded()
如果使用 load
成功以指定書籍初始化檢視器,則傳回 true。
影片簡介
highlight(opt_string)
參數:
string opt_string
- 要醒目顯示的字串。如果是 null
或 undefined
,則會關閉醒目顯示功能。
load
load(identifiers, opt_notFoundCallback, opt_successCallback)
參數:
string, Array of strings identifiers
- 預覽網址或書籍 ID,例如 ISBN、OCLC 等。請參閱動態連結要求格式。如要為書籍指定多個替代 ID (例如精裝書和平裝書的 ISBN),請傳遞這些 ID 字串的 Array
;觀眾將會載入陣列中的第一本可嵌入的書籍。
Function opt_notFoundCallback
- 如果 identifier
是書籍 ID,則在找不到書籍時會呼叫這個回呼。如果傳遞 null
或省略這個參數,系統就不會在失敗時呼叫任何函式。
Function opt_successCallback
- 如果檢視器已成功以特定書籍例項化,且已準備好接收 nextPage
等函式呼叫,系統就會執行這個回呼。
nextPage
nextPage()
previousPage
previousPage()
resize
resize()
zoomIn
zoomIn()
zoomOut
zoomOut()
返回頁首
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-11-08 (世界標準時間)。
[null,null,["上次更新時間:2024-11-08 (世界標準時間)。"],[[["\u003cp\u003eThe Embedded Viewer API allows you to embed a Google Book into your webpage using the \u003ccode\u003egoogle.books.DefaultViewer\u003c/code\u003e class.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods for navigation such as \u003ccode\u003enextPage\u003c/code\u003e, \u003ccode\u003epreviousPage\u003c/code\u003e, \u003ccode\u003egoToPage\u003c/code\u003e, and \u003ccode\u003egoToPageId\u003c/code\u003e, as well as zooming and highlighting functionalities.\u003c/p\u003e\n"],["\u003cp\u003eYou can load a book using identifiers like ISBN or OCLC with the \u003ccode\u003eload\u003c/code\u003e method and handle loading success or failure with callbacks.\u003c/p\u003e\n"],["\u003cp\u003eThe viewer can be resized dynamically with \u003ccode\u003eresize\u003c/code\u003e and provides methods to retrieve current page information like \u003ccode\u003egetPageNumber\u003c/code\u003e and \u003ccode\u003egetPageId\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Reference\n\nThe Embedded Viewer API contains one class: DefaultViewer. For an introduction to using the API, see the [Developer's Guide](/books/docs/viewer/developers_guide).\n\nConstructor summary\n-------------------\n\n`\n`**[google.books.DefaultViewer](#google.books.DefaultViewer)**`(div, opt_options)\n`\n: An embedded viewer for a volume in Google Book Search.\n\nMethod summary\n--------------\n\n`string\n`**[getPageNumber](#google.books.DefaultViewer.getPageNumber)**`() `\n: Returns the page number of the page that's currently visible in\n the viewport.\n\n`string\n`**[getPageId](#google.books.DefaultViewer.getPageId)**`() `\n: Returns a unique identifier for the page that's currently visible in the\n viewport.\n\n`boolean\n`**[goToPage](#google.books.DefaultViewer.goToPage)**`(pageNumber) `\n: Returns true if the page exists and was turned to.\n\n`boolean\n`**[goToPageId](#google.books.DefaultViewer.goToPageId)**`(pageId) `\n: Returns true if the page exists and was turned to.\n\n`boolean\n`**[isLoaded](#google.books.DefaultViewer.isLoaded)()**\n: Indicates whether the viewer has been successfully initialized with the given book.\n\n`\n`**[highlight](#google.books.DefaultViewer.highlight)**`(opt_string) `\n: Highlights a term in the viewport.\n\n`\n`**[load](#google.books.DefaultViewer.load)**`(identifiers, opt_notFoundCallback, opt_successCallback) `\n: Loads a book in the viewport.\n\n`\n`**[nextPage](#google.books.DefaultViewer.nextPage)**`() `\n: Goes to the next page in the book.\n\n`\n`**[previousPage](#google.books.DefaultViewer.previousPage)**`() `\n: Goes to the previous page in the book.\n\n`\n`**[resize](#google.books.DefaultViewer.resize)**`() `\n: Resizes the viewer to conform to size of its container div.\n\n`\n`**[zoomIn](#google.books.DefaultViewer.zoomIn)**`() `\n: Zooms into the viewer.\n\n`\n`**[zoomOut](#google.books.DefaultViewer.zoomOut)**`() `\n: Zooms out of the viewer.\n\nConstructor detail\n------------------\n\n### google.books.DefaultViewer\n\n```\ngoogle.books.DefaultViewer(div, opt_options)\n```\n\nAn embedded viewer for a volume in Google Book Search.\n\n\u003c!-- --\u003e\n\n**Parameters:** *Element*` div` - Div to draw the viewport in.\n\u003c!-- --\u003e\n\n*Object*` opt_options` - Key-value map of options to pass along to the viewer.\n\nMethod detail\n-------------\n\n### getPageNumber\n\n```\nstring getPageNumber()\n```\n\nReturns the page number of the page that's currently visible in the viewport.\n\n\u003c!-- --\u003e\n\n**Returns:** *string*` `\n\n### getPageId\n\n```\nstring getPageId()\n```\n\nReturns a unique identifier for the page that's currently visible in the viewport.\n\n\u003c!-- --\u003e\n\n**Returns:** *string*` `\n\n### goToPage\n\n```\nboolean goToPage(pageNumber)\n```\n\nReturns true if the page exists and was turned to.\n\n\u003c!-- --\u003e\n\n**Parameters:** *string, number*` pageNumber ` - The page number of the page to turn to.\n\n\u003c!-- --\u003e\n\n**Returns:** *boolean*` `\n\n### goToPageId\n\n```\nboolean goToPageId(pageId)\n```\n\nReturns true if the page exists and was turned to.\n\n\u003c!-- --\u003e\n\n**Parameters:** *string*` pageId ` - The unique identifier of the page to turn to.\n\n\u003c!-- --\u003e\n\n**Returns:** *boolean*` `\n\n### isLoaded\n\n```\nboolean isLoaded()\n```\n\nReturns true if the viewer has been successfully initialized with the given book using `load`.\n\n\u003c!-- --\u003e\n\n**Returns:** *boolean*` `\n\n### highlight\n\n```\nhighlight(opt_string)\n```\n\nHighlights a term in the viewport.\n\n\u003c!-- --\u003e\n\n**Parameters:** *string*` opt_string ` - A string to highlight. Turns off highlighting if `null` or `undefined`.\n\n### load\n\n```\nload(identifiers, opt_notFoundCallback, opt_successCallback)\n```\n\nLoads a book in the viewport.\n\n\u003c!-- --\u003e\n\n**Parameters:** *string* `, `*Array of strings*` identifiers ` - A preview URL or book identifier such as an ISBN, OCLC, etc. See [Dynamic Links request format](/books/docs/dynamic-links#requestFormat). To specify several alternative identifiers for the book (e.g., the hardcover and softcover ISBNs), pass an `Array` of these identifier strings; the viewer will the viewer will load the first embeddable book in the array.\n\u003c!-- --\u003e\n\n*Function*` opt_notFoundCallback ` - If `identifier` is a book identifier, this callback will be called if the book was not found. If `null` passed or this parameter is omitted, no function will be called on failure.\n\u003c!-- --\u003e\n\n*Function*` opt_successCallback ` - This callback will be executed if and when the viewer is successfully instantiated with a particular book, and ready to receive function calls such as `nextPage`.\n\n### nextPage\n\n```\nnextPage()\n```\n\nGoes to the next page in the book.\n\n### previousPage\n\n```\npreviousPage()\n```\n\nGoes to the previous page in the book.\n\n### resize\n\n```\nresize()\n```\n\nResizes the viewer to conform to size of its container div.\n\n### zoomIn\n\n```\nzoomIn()\n```\n\nZooms into the viewer.\n\n### zoomOut\n\n```\nzoomOut()\n```\n\nZooms out of the viewer.\n\n[Back to top](#top)"]]