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

window.onIssuuReadersLoaded:function

Callback function, called when a viewer is loaded.

window.IssuuReaders.get(embedId:String):viewer

Returns the viewer object for a specific embedId.

window.IssuuReaders.add():void

Scans the page and renders the embeds which have not been rendered before.

viewer.getPageNumber():int

Returns the page number of the page currently being viewed.

viewer.setPageNumber(value:int):void

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

viewer.getPageCount():int

Returns the total number of pages that can be viewed.

viewer.goToPreviousPage():void

Asks the viewer to flip to the previous page.

viewer.goToNextPage():void

Asks the viewer to flip to the next page.

viewer.goToFirstPage():void

Asks the viewer to flip to the first page.

viewer.goToLastPage():void

Asks the viewer to flip to the last page.

Event handling

viewer.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.

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


<!-- Your embed code.-->
<div data-configid="0/1000660" style="width: 420px; height: 300px;" class="issuuembed"></div>
<script type="text/javascript" src="//e.issuu.com/embed.js" async="true"></script>

<!-- ISSUU javascript API.-->
<script type="text/javascript" charset="utf-8">
window.onIssuuReadersLoaded = function() {
var viewer = window.IssuuReaders.get("0/1000660");
// Add listener for 'change' event, and flip to page 2.
viewer.addEventListener("change", "viewerChangeHandler");
viewer.setPageNumber(2);
};
</script>

See the example controlled by JavaScript .

Limitations