0

I am scrolling a pdf file inside an Iframe and trying to access the scroll position but failed to do so. tried all the resources but they don't seem to work anymore. Any help is Greatly Appreciated.

const iframe = document.getElementById('iframe');

iframe.onload = function() {
  console.log("IFrame Loaded")
  const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
  iframeDoc.addEventListener('scroll', function() {
  console.log("Scrolling Started")
  console.log(iframeDoc.documentElement.scrollTop);
});
};
  • Are there any errors in the console? For example: `Uncaught DOMException: Permission denied to access property "document" on cross-origin object`? – FiddlingAway Feb 10 '23 at 21:56
  • No i don't see any errors in the console. It just does not enter the 'scroll' event listener. – Mayank Feb 20 '23 at 13:05

0 Answers0