1.0.0 • Published 8 years ago

electron-run-in-browser v1.0.0

Weekly downloads
1
License
MIT
Repository
-
Last release
8 years ago

electron-run-in-browser

Run some js in a BrowserWindow and get the result.

Usage

runInBrowser(win, func, cb)

  • win: BrowserWindow instance.
  • func: function. Serialized with toString so it needs to be self-contained.
  • cb: callback function, called with (err, result)

Example

const BrowserWindow = require('electron').BrowserWindow
const runInBrowser = require('electron-run-in-browser')

const win = new BrowserWindow()

win.webContents.on('dom-ready', function (e) {
  runInBrowser(win, getDocumentTitle, function (err, title) {
    console.log('title:', title)
  })
})

function getDocumentTitle () {
  return document.title
}

License

MIT