Skip to content
DearFlip JS Flipbook
  • Plugins
    • WordPress Flipbook
    • Joomla Flipbook
    • Javascript Flipbook
  • Demos
    • Embedded Example
    • Popup Examples
    • Online PDF Viewer
  • Pricing
  • Docs
  • Support
  • Account
  • Blog
DearFlip JS Flipbook
  • Plugins
    • WordPress Flipbook
    • Joomla Flipbook
    • Javascript Flipbook
  • Demos
    • Embedded Example
    • Popup Examples
    • Online PDF Viewer
  • Pricing
  • Docs
  • Support
  • Account
  • Blog

Getting Started

  • Getting started
  • File Structure & Template
  • Basic Usages
  • Options List

FAQs

  • Support and FAQs
  • License Activation
  • Why are there PHP files in download zip file?

Examples

  • Examples
  • Basic – Flipbook using HTML
  • Basic – Using options
  • Adding Outline/Table of Content
  • Adding Search

Customizations

  • onPageChanged
  • Customizations
  • Open flipbook in full-screen
  • onReady Function
  • PDF links custom class and usages
  • Update URL hash on the address bar when a page flips
  • How to add custom share button?

Advanced Customizations

  • Add Close button to ToolBar
  • Advanced Customizations
  • Store last viewed flipbook page
  • Add Custom Button to Flipbook
  • Add Custom Download button to Flipbook
  • Add print button to flipbook
  • Add Custom Zoom Reset button to Flipbook
  • Thumb animation on page scroll
  • Load more button for lightboxes
  • Reset flipbook zoom on flip
View Categories
  • Home
  • Documentation
  • Advanced Customizations
  • Store last viewed flipbook page

Store last viewed flipbook page

Experimental customizations are not included by default and are extended to the plugin. Please use with caution and proper consent.

Case: #

Flipbook can open at any given page by using data-page=5 setting(second Book), or by passing through options
var options={openPage:5};

Yet, at times last open page of user can be stored and restored using further customization.


Demo: #

Open Book
Book 1 Manual
Book 2 Template
Book 2 will open at page 5, until user flips it, then after user location is stored and used. It resets back to page 5 once you clear data.
Clear Data

Process: #

Lets create two popup books that have distinct id “book1” and “book2”. These id will be used to store the position of the page.

<div class="_df_button" id="book1" source="https://js.dearflip.com/wp-content/uploads/2019/07/dearpdf-manual.pdf">Book 1 Manual</div>

<div class="_df_button" id="book2" source="https://js.dearflip.com/wp-content/uploads/2019/07/glfw.pdf" data-page=5>Book 2 Template</div>

We use onCreate function to restore the last page and onFlip to store the current page in a flipbook. These are added to DFLIP.defaults variable so that every flipbook on the page uses the customization.

//Version 2.0 and above
jQuery(function(){

DFLIP.defaults.onCreate = function(flipbook){
    var page = localStorage.getItem(flipbook.options.id);
    if(page !==null){
        flipbook.currentPageNumber = parseInt(page,10);
        console.log("Flipbook : " + flipbook.options.id + " Restored at : " + flipbook.options.openPage); 
    }
};

DFLIP.defaults.onFlip = function(flipbook) {
    console.log("Flipbook : " + flipbook.options.id + "stored at : " + flipbook.currentPageNumber);
    localStorage.setItem(flipbook.options.id,flipbook.currentPageNumber);
};

    jQuery("#clear_data").on("click",function(){
        localStorage.removeItem("book1");localStorage.removeItem("book2");
        alert("Data Cleared Successfully");
    });

});

//Version less than 2.0
jQuery(function(){

    DFLIP.defaults.onCreate = function(flipbook){
        var page = localStorage.getItem(flipbook.options.id);
        if(page !==null){
            flipbook.options.openPage = page;
            console.log("Flipbook : " + flipbook.options.id + " Restored at : " + flipbook.options.openPage); 
        }
    };
    
    DFLIP.defaults.onFlip = function(flipbook) {
        console.log("Flipbook : " + flipbook.options.id + "stored at : " + flipbook.target._activePage);
        localStorage.setItem(flipbook.options.id,flipbook.target._activePage);
    };

    jQuery("#clear_data").on("click",function(){
        localStorage.removeItem("book1");localStorage.removeItem("book2");
        alert("Data Cleared Successfully");
    });

});

localStorage is used for this example. It can be changed to another library or storage location based on the requrement.

Updated on October 13, 2023

More Inquiry/Info & COMMENTS:

All DearFlip comments and discussion have been moved to
https://github.com/dearhive/dearflip-js-flipbook/discussions

Table of Contents
  • Case:
  • Demo:
  • Process:

Links

  • Terms and Conditions
  • License Terms
  • Privacy Policy

Recent Posts

  • Best Flipbook Javascript Plugins with Pros and Cons
  • PDF Partial Loading – What, How and Why?
  • PDF Hyper Links are not working? What is the issue?
  • How flipbook size works? How to make it bigger?
  • Customizing Buttons

Products

  • DearFlip WordPress Flipbook
  • DearFlip 3D Flipbook JS Plugin
  • Online PDF Viewer
  • DearFlip PDF Flipbook for Chrome
© 2025 | A product of DearHive.com