title: On clicking button to run function in Electron program, page contents are cleared and function does not run
body: <p>I have a very strange error. When I click a button to run a function <code>open()</code> the function does not run (<code>console.log</code> does not log anything). However, in Developer Tools, when I go to console and run <code>open()</code>, it seems to run perfectly fine.</p>
  
  <p><code>open()</code> is used to open a file open dialog.</p>
  
  <p>Here is the button:</p>
  
  <pre><code>&lt;button class="w3-button" id="openButton" onclick="open();"&gt;Open&lt;/button&gt;
  </code></pre>
  
  <p>Here is <code>open()</code> in <code>scripts.js</code> (referenced by the HTML file):</p>
  
  <pre><code>//open file
  function open() {
    ipcRenderer.send('openFile', {});
    console.log("wtf?");
    //judging by absence of above statement on button click, this is probably a HTML problem...?
  }
  </code></pre>
  
  <p>Here is the function that is supposed to open the dialog in <code>main.js</code>:</p>
  
  <pre><code>ipcMain.on('openFile', function () {
    //show open dialog
    dialog.showOpenDialog({
      defaultPath: '~/',
      filters: [
        {name: 'Text Files', extensions: ['txt']},
        {name: 'All Files', extensions: ['*']}
      ]
    }, function() {
      console.log("wtf?");
      //open the file
      fs.readFile();
    });
  });
  </code></pre>