title: How to access the mainWindow from another script in Electron?
body: <p>My electron app defines the <code>BrowserWindow</code> <em>mainWindow</em> in the <em>main.js</em>. It loads an html and eventually inside of the html a script runs the function <a href="https://github.com/electron/electron/blob/master/docs/api/dialog.md#dialogshowmessageboxbrowserwindow-options-callback" rel="noreferrer"><code>dialog.showMessageBox()</code></a> which displays a simple warning:</p>
  
  <pre><code>dialog.showMessageBox({
      type: 'warning',
      message: "You have been warned.",
      buttons: ["OK"]
  });
  </code></pre>
  
  <p>I want this dialog to be a child of the <em>mainWindow</em> b/c that makes it a modal, which disables the <em>mainWindow</em> until it is closed. To implement this you normally would just add <code>mainWindow,</code>before the type declaration. Unfortunately it doesn't know the variable <em>mainWindow</em> since the <a href="https://github.com/electron/electron/blob/master/docs/api/dialog.md#dialogshowmessageboxbrowserwindow-options-callback" rel="noreferrer"><code>dialog.showMessageBox()</code></a> is created in a different script (<em>site.js</em>).</p>
  
  <p>How can I create a dialog, that is a child of the <em>mainWindow</em> without creating it in the <em>main.js</em>? 
  Can <a href="https://electronjs.org/docs/api/ipc-renderer" rel="noreferrer">ipc</a> help somehow?</p>