alexandernst
alexandernst

Reputation: 15099

Open an iframe with a URL and then run some JS

I'm building an app using Atom Shell, and I'm trying to open an iframe which would load a PDF file, and then, once the PDF file is fully loaded, run some JS from the scope of that iframe (I'm willing to run Browser->Print (https://github.com/atom/atom-shell/blob/master/docs/api/browser-window.md#browserwindowprintoptions).

Is that possible? If so, how?

Upvotes: 0

Views: 524

Answers (1)

Clark
Clark

Reputation: 406

Depends on where the PDF file is hosted, but usually the process goes like this:

  1. create a new browser window object with the size/configs desire for you 'iframe' that isn't going to be an actual iframe
  2. .show() the browser window
  3. .loadUrl(INSERT_PDF_URL) into the browser window
  4. listen on browser window webContents 'did-finish-loading' event, and then either run your JS if it is on the browser side, or .executeJavaScript(YOUR_JS_HERE) if you need it to be run on the renderer side (within the browser window)

Upvotes: 1

Related Questions