Cordova application located on server (not on device) - Events do not fire
<p>I am writing a cordova (version 6) application for an Android 4.4 device. Here I am trying to catch the button-press events, e.g. <kbd>volume-down</kbd> button. Unfortunately I need to host the app on a server. Meaning all the html, css and js files are loaded remotely. Whereas the <code>index.html</code> of the app itself only contains: </p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;meta charset="UTF-8"&gt;
    &lt;meta http-equiv="Content-Security-Policy" /&gt;
    &lt;meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/&gt;
    &lt;title&gt;My App&lt;/title&gt;

    &lt;script type="text/javascript"&gt;
      function init() {
        window.location.href="http://example.com:3000/myapp";
      }
    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body id="body" onload="init();"&gt;
  &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>On the server-side the cordova-js gets successfully injected with:
<code>&lt;script type="text/javascript" src="/assets/cordova.js"&gt;&lt;/script&gt;</code></p>

<p>I have built the cordova-js by myself, using this repository and their documentation: <a href="https://github.com/apache/cordova-js" rel="nofollow">https://github.com/apache/cordova-js</a></p>

<hr>

<p>Most of the server-side cordova code is running fine! E.g. I have added some plugins which all work (wifi-information, show-toast-messages, and so on...). But unfortunately the button-listeners for <kbd>menu</kbd>, <kbd>back</kbd>, <kbd>volup</kbd>, <kbd>voldown</kbd> are not working anymore! They used to work, when the cordova code was loaded directly on the device, but since I put in on a remote server it doesn't work anymore.</p>

<p><strong>JS-file from Server:</strong></p>

<pre><code>//Gets called from the body-tag of the html-site - works!
function onLoad() {
    document.addEventListener("deviceready", onDeviceReady, false);
}

function onDeviceReady() {
  //This works!
  console.log("onDeviceReady");

  //This doesn't do anything (but also no error messages)
  navigator.app.overrideButton("backbutton", true);
  navigator.app.overrideButton("menubutton", true);
  document.addEventListener("backbutton", onBackKeyDown, false);
  document.addEventListener("volumeupbutton", onVolumeUpKeyDown, false);
  document.addEventListener("menubutton", onMenuKeyDown, false);

  //Plugins that are loaded from here all work!
}

function onMenuKeyDown(event) {
  //This doesn't work
  console.log("menu pressed");
}

function onBackKeyDown(event) {
  //This doesn't work
  console.log("back pressed");
}

function onVolumeUpKeyDown() {
  //This doesn't work
  console.log("Volume up pressed");
}
</code></pre>

<p>Can someone tell me, why this code isn't working anymore and help me fix this?</p>