Tài liệu tham khảo
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
API Trình xem được nhúng chứa một lớp: DefaultViewer. Để tìm hiểu hướng dẫn sử dụng API này, hãy xem Hướng dẫn cho nhà phát triển.
Tóm tắt về hàm khởi tạo
google.books.DefaultViewer(div, opt_options)
- Một trình xem được nhúng cho một tập trong Tìm kiếm Sách của Google.
Tóm tắt phương thức
string
getPageNumber()
- Trả về số trang của trang hiện đang hiển thị trong khung nhìn.
string
getPageId()
- Trả về giá trị nhận dạng duy nhất cho trang hiện hiển thị trong khung nhìn.
boolean
goToPage(pageNumber)
- Trả về true nếu trang tồn tại và đã được chuyển đến.
boolean
goToPageId(pageId)
- Trả về true nếu trang đã tồn tại và bạn đã chuyển sang.
boolean
isLoaded()
- Cho biết trình xem đã được khởi chạy thành công bằng cuốn sách nhất định hay chưa.
highlight(opt_string)
- Đánh dấu một từ khoá trong khung nhìn.
load(identifiers, opt_notFoundCallback, opt_successCallback)
- Tải sách trong khung nhìn.
nextPage()
- Chuyển đến trang tiếp theo trong sách.
previousPage()
- Chuyển đến trang trước trong sách.
resize()
- Đổi kích thước trình xem để phù hợp với kích thước của div vùng chứa.
zoomIn()
- Phóng to vào trình xem.
zoomOut()
- Thu nhỏ trình xem.
Thông tin chi tiết về hàm khởi tạo
google.books.DefaultViewer
google.books.DefaultViewer(div, opt_options)
Trình xem được nhúng cho một tập trong Google Tìm kiếm sách.
Tham số:
Element div
– Div để vẽ khung nhìn.
Object opt_options
– Sơ đồ khoá-giá trị của các tuỳ chọn để chuyển cho người xem.
Chi tiết phương thức
getPageNumber
string getPageNumber()
Trả về số trang của trang hiện hiển thị trong
khung nhìn.
getPageId
string getPageId()
Trả về giá trị nhận dạng duy nhất cho trang hiện hiển thị trong
khung nhìn.
goToPage
boolean goToPage(pageNumber)
Trả về giá trị true nếu trang tồn tại và đã được chuyển đến.
Thông số:
string, number pageNumber
– Số trang của trang cần chuyển đến.
goToPageId
boolean goToPageId(pageId)
Trả về giá trị true nếu trang tồn tại và đã được chuyển đến.
Thông số:
string pageId
– Giá trị nhận dạng duy nhất của trang cần truy cập.
isLoaded
boolean isLoaded()
Trả về true nếu trình xem đã được khởi động thành công bằng cuốn sách đã cho bằng load
.
tiêu điểm
highlight(opt_string)
Làm nổi bật một từ khoá trong khung nhìn.
Thông số:
string opt_string
– Chuỗi cần đánh dấu. Tắt tính năng đánh dấu nếu
null
hoặc undefined
.
trọng tải
load(identifiers, opt_notFoundCallback, opt_successCallback)
Tải sách trong khung nhìn.
Tham số:
string, Array of strings identifiers
– URL xem trước hoặc giá trị nhận dạng sách, chẳng hạn như ISBN,
OCLC, v.v. Hãy xem Định dạng yêu cầu Đường liên kết động. Để chỉ định một vài giá trị nhận dạng thay thế cho sách (ví dụ: ISBN bìa cứng và bìa mềm), hãy truyền Array
trong số các chuỗi giá trị nhận dạng này; người xem sẽ tải cuốn sách có thể nhúng đầu tiên vào mảng.
Function opt_notFoundCallback
– Nếu identifier
là giá trị nhận dạng cuốn sách, lệnh gọi lại này sẽ được gọi nếu không tìm thấy cuốn sách. Nếu truyền null
hoặc tham số này bị bỏ qua, thì sẽ không có hàm nào được gọi khi không thành công.
Function opt_successCallback
– Lệnh gọi lại này sẽ được thực thi
nếu và khi trình xem được tạo bản sao thành công bằng một cuốn sách cụ thể và sẵn sàng
nhận các lệnh gọi hàm như nextPage
.
nextPage
nextPage()
Chuyển đến trang tiếp theo trong sách.
previousPage
previousPage()
Chuyển đến trang trước trong sách.
đổi kích thước
resize()
Đổi kích thước trình xem cho phù hợp với kích thước của div vùng chứa.
zoomIn
zoomIn()
zoomOut
zoomOut()
Trở lại đầu trang
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2024-11-08 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2024-11-08 UTC."],[[["\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)"]]