LogoLogo
  • iPaper Technical Documentation
  • Display Analytics
    • Google Analytics
  • Display JavaScript API
    • Quick Start
    • Commands
    • Events
  • Flipbook Analytics
    • Adobe Analytics events
    • Google Analytics / GTM events
  • Flipbook Backend API
    • Overview
    • Return Codes
    • Ecommerce
      • GetFlipbookOrdersByType
      • GetLicenseOrdersByType
    • Image
      • GetImageWith2PxDropShadow
    • Link
      • GetLinks
    • Media
      • CreateDirectory
      • DeleteDirectory
      • DeleteFile
      • GetTree
      • UploadFile
    • Paper
      • ChangePaperUrl
      • ClearPublicationPeriod
      • CreateCategory
      • CreatePaper
      • CreatePreviewToken
      • DeletePaper
      • GetAllPapers
      • GetPaperIDFromUrl
      • GetPaperStructure
      • GetPaperUrlFromID
      • GetSetting
      • GetSettingDescriptions
      • MovePaper
      • SetPublicationPeriod
      • SetSetting
    • Ripper
      • GetProcessingPapers
      • GetProcessingStatus
      • ProcessPDF
      • ReprocessPaper
    • Search
      • SearchPapersByContent
      • SearchPapersByCustomFields
      • SearchPapersWithHiearchyByContent
      • SearchPapersWithHiearchyByName
    • Statistics
      • GetNumberOfPageviewsPerDay
      • GetNumberOfVisitors
      • GetNumberOfVisitorsPerDay
  • Flipbook Enrichment
    • Popup Content
    • Popup Frame
  • Flipbook Integration
    • Custom Domain
    • Custom Mail
    • Embedding flipbooks inside iOS and Android App
    • Form Integration
    • Iframing Flipbooks
    • iPaper Embed Script (Pop-ups)
    • Embeds (Minipapers)
    • Query String Parameters
    • Remote Authentication
    • Shop Export
  • Flipbook JavaScript API
    • Getting Started
    • Commands & Events
      • Basket
      • Consent
        • Example Implementations
          • UserCentrics
          • OneTrust
          • CookieInformation
          • Cookiebot
      • Paging
      • Publication
      • Search
      • Table of Contents
      • Sharing
    • Advanced Usage
    • Migration guide
    • Legacy Javascript API (v2)
      • Quick Start
      • Commands
      • Events
      • Consent Management
      • Advanced Usage
  • Technical Information
    • Cookie Information
    • Common security questions
    • Open Source
Powered by GitBook
On this page
  • Overview
  • Flipbook-related commands
  • updateEventSettings
  • Publication-related commands
  • goToPage
  • goToPreviousPage
  • goToNextPage
  • Shop-related commands
  • addItem
  • Advanced use
  1. Flipbook JavaScript API
  2. Legacy Javascript API (v2)

Commands

Commands are instructions issued by the parent window to the iframed flipbook. Commands can be invoked by calling magic methods, which can be accessed directly from the API instance.

PreviousQuick StartNextEvents

Last updated 1 year ago

Overview

Commands are issued from the parent window (your website) to the JavaScript API. The API then relays the command via window.postMessage() to the iframed flipbook.

Flipbook-related commands

updateEventSettings

It is possible to dictate how the iframed flipbook should handle events when they have been triggered. The method accepts a single argument that is an object containing the following keys, which references events that the v2 Flipbook API listens to:

The keys should contain an object of the following format: { preventDefault: <boolean> }, where <boolean> is true or false. When preventDefault is set to true, the flipbook will skip the default action associated with each event. If set to false, the default action will be performed.

Event
Default action taking place in the flipbook

Opens the shop basket

Adds the item to the shop basket. Triggered by any enrichment that adds a shop item (e.g. shop variant menu).

An example use:

// Disable opening of shop basket AND adding shop items
iPaperAPI.updateEventSettings({
	onBasketClick: { preventDefault: true },
	onItemAdd: { preventDefault: true }
});

Publication-related commands

goToPage

Navigate to a specific page: the page number is to be provided as the one and only argument of the function. For example:

iPaperAPI.goToPage(4);

goToPreviousPage

Go to the previous spread (if flipbook has a spread-based layout), or the previous page (if flipbook has a page-based layout). This method accepts no arguments:

iPaperAPI.goToPreviousPage();

goToNextPage

Go to the next spread (if flipbook has a spread-based layout), or the next page (if flipbook has a page-based layout). This method accepts no arguments:

iPaperAPI.goToNextPage();

Shop-related commands

addItem

Programmatically adds a custom item to the basket. This method accepts a single argument, consisting of properties of the shop item entity.

Property
Type
Description

title

string

Shop item title

description

string

Shop item description

productID

string

Shop item product ID

originPage

number

Page number where the shop item is located

price

number

Shop item price

quantity

number

Number of items added

Example use:

iPaperAPI.addItem({
    title: 'My product',
    description: 'Product description',
    productID: 'PROD-25B',
    price: '29.95',
    originPage: 6,
    quantity: 1
});

Advanced use

If you are accustomed to the .trigger() regime (such as that implemented in JQuery), you can also use it as such:

iPaperAPI.trigger('goToPage', 4);

Refer to on the advanced usage page for a wholesome example.

onBasketClick
onItemAdd
onBasketClick
onItemAdd
Event listeners and command triggers