How to call a custom function implemented inside config.js from outside the iframe

36 views
Skip to first unread message

Euan Carmichael

unread,
Jul 17, 2018, 4:42:06 PM7/17/18
to PDFTron WebViewer
Q: I have implemented a custom function inside my config.js file that I want to call from outside the WebViewer iframe, how can I do this?

A: To achieve this you can append the function to the readerControl object inside the iframe and then access the function via that object:

Config.js:

$(document).on('viewerLoaded',
 
function() {

    readerControl.myFunction = function() {  

    console.log('hello world');

  };

});


outside the iframe:

$(viewerElement).on('documentLoaded',
function() {

  myWebViewer.getInstance().myFunction();

});


See the user-guides for more information on accessing the WebViewer objects from outside the iframe: https://www.pdftron.com/documentation/web/guides/fundamentals/html-structure

Reply all
Reply to author
Forward
0 new messages