title: How to call a JavaScript function on a web page rendered by Electron?
body: <p>I'm trying to write a wrapper for <a href="https://twitter.com" rel="noreferrer">Twitter</a> using <a href="http://electron.atom.io/" rel="noreferrer">Electron</a> (formerly Atom Shell).</p>
  
  <p>My <code>main.js</code> file (it looks almost identical to the "<a href="https://github.com/dougnukem/hello-atom" rel="noreferrer">Hello World</a>" example, I just changed it in one place):</p>
  
  <pre class="lang-js prettyprint-override"><code>var app = require('app');  // Module to control application life.
  var BrowserWindow = require('browser-window');  // Module to create native browser window.
  
  // Report crashes to our server.
  require('crash-reporter').start();
  
  // Keep a global reference of the window object, if you don't, the window will
  // be closed automatically when the javascript object is GCed.
  var mainWindow = null;
  
  // Quit when all windows are closed.
  app.on('window-all-closed', function() {
    if (process.platform != 'darwin')
      app.quit();
  });
  
  // This method will be called when atom-shell has done everything
  // initialization and ready for creating browser windows.
  app.on('ready', function() {
  
    // Create the browser window.
    mainWindow = new BrowserWindow ({'width':1000,'height':600});
    // and load the index.html of the app.
    mainWindow.loadUrl('https://twitter.com');
  
    // Emitted when the window is closed.
    mainWindow.on('closed', function() {
      // Dereference the window object, usually you would store windows
      // in an array if your app supports multi windows, this is the time
      // when you should delete the corresponding element.
      mainWindow = null;
    });
  });
  </code></pre>
  
  <p>I try to call <code>alert()</code> function right after <code>mainWindow.loadUrl()</code> but it does not execute.</p>
  
  <p>I understand that <code>main.js</code> file is like the server side of my app, but the question is... How can I call a JavaScript function on page? Where should I write the code?</p>
  
  <p>For example, I want to perform this:</p>
  
  <pre class="lang-js prettyprint-override"><code>$(document).ready(function() {
      alert("Hurray!");
  });
  </code></pre>