Viewer JavaScript API

The Issuu publication viewer can be controlled from within the host web page using JavaScript method calls and events. This document describes the JavaScript programming interface (API).

Methods

Viewer API

getPageNumber():int

Returns the page number of the page currently being viewed.

setPageNumber(value:int):void

Sets the page number to be viewed. The viewer flips to the specified page and dispatches the change event.

getPageCount():int

Returns the total number of pages that can be viewed.

goToPreviousPage():void

Asks the viewer to flip to the previous page.

goToNextPage():void

Asks the viewer to flip to the next page.

goToFirstPage():void

Asks the viewer to flip to the first page.

goToLastPage():void

Asks the viewer to flip to the last page.

Event handling

addEventListener(type:String, listener:String):void

Adds a listener for a specified event. The value of the listener argument is the name of the JavaScript function to call in response to the event.

goToLastPage():void

Asks the viewer to flip to the last page.

Events

change

Dispatched when the page number being viewed has changed. This may happen as a result of user interaction or in response to an API method call like setPageNumber, goToPreviousPage, etc.

Example

var viewer = document.getElementById("issuuViewer");

// Add listener for 'change' event, and flip to page 2.
viewer.addEventListener("change", "viewerChangeHandler");
viewer.setPageNumber(2);

Read the Getting Started tutorial.