diff --git a/pgweb/downloads/views.py b/pgweb/downloads/views.py
index 3d50765..bf87189 100644
--- a/pgweb/downloads/views.py
+++ b/pgweb/downloads/views.py
@@ -194,6 +194,11 @@ def mirrorselect(request, path):
     return HttpResponseRedirect("https://ftp.postgresql.org/pub/%s" % path)
 
 
+# Render javascript for apt downloads
+def apt_js(request):
+    return render(request, 'downloads/js/apt.js', content_type='application/javascript')
+
+
 # Render javascript for yum downloads
 def yum_js(request):
     with open(settings.YUM_JSON) as f:
diff --git a/pgweb/urls.py b/pgweb/urls.py
index 3d4d0ca..52c2aba 100644
--- a/pgweb/urls.py
+++ b/pgweb/urls.py
@@ -48,6 +48,7 @@ urlpatterns = [
     url(r'^applications-v2.xml$', pgweb.downloads.views.applications_v2_xml),
     url(r'^download/uploadftp/', pgweb.downloads.views.uploadftp),
     url(r'^download/uploadyum/', pgweb.downloads.views.uploadyum),
+    url(r'^download/js/apt.js', pgweb.downloads.views.apt_js),
     url(r'^download/js/yum.js', pgweb.downloads.views.yum_js),
 
     url(r'^docs/$', pgweb.docs.views.root),
diff --git a/templates/downloads/js/apt.js b/templates/downloads/js/apt.js
index e69de29..333b429 100644
--- a/templates/downloads/js/apt.js
+++ b/templates/downloads/js/apt.js
@@ -0,0 +1,8 @@
+/* Event handlers */
+function setupHandlers() {
+    document.getElementById('copy-btn').addEventListener('click', function () {
+        copyScript(this, 'script-box');
+    });
+}
+
+document.addEventListener("DOMContentLoaded", setupHandlers);
diff --git a/templates/downloads/js/yum.js b/templates/downloads/js/yum.js
index e5f8897..52dcdd6 100644
--- a/templates/downloads/js/yum.js
+++ b/templates/downloads/js/yum.js
@@ -158,3 +158,15 @@ function archChanged() {
 
    document.getElementById('copy-btn').style.display = 'block';
 }
+
+/* Event handlers */
+function setupHandlers() {
+    document.getElementById('copy-btn').addEventListener('click', function () {
+        copyScript(this, 'script-box');
+    });
+    document.getElementById('version').addEventListener('change', verChanged);
+    document.getElementById('platform').addEventListener('change', platChanged);
+    document.getElementById('arch').addEventListener('change', archChanged);
+}
+
+document.addEventListener("DOMContentLoaded", setupHandlers);
diff --git a/templates/pages/download/linux/debian.html b/templates/pages/download/linux/debian.html
index a3bc977..d8900cb 100644
--- a/templates/pages/download/linux/debian.html
+++ b/templates/pages/download/linux/debian.html
@@ -1,5 +1,8 @@
 {%extends "base/page.html"%}
 {%block title%}Linux downloads (Debian){%endblock%}
+{%block extrahead%}
+<script type="text/javascript" src="/download/js/apt.js?{{gitrev}}"></script>
+{%endblock%}
 {%block contents%}
 
 <h1>Linux downloads (Debian) <img class="logo" src="/media/img/debian.svg" alt="Debian Logo" /></h1>
@@ -55,7 +58,7 @@ sudo apt-get update
 # Install the latest version of PostgreSQL.
 # If you want a specific version, use 'postgresql-12' or similar instead of 'postgresql':
 sudo apt-get install postgresql</pre>
-    <button class="pg-script-copy-btn" onclick="copyScript(this, 'script-box')">Copy Script</button>
+    <button id="copy-btn" class="pg-script-copy-btn">Copy Script</button>
 </div>
 
 <p>
diff --git a/templates/pages/download/linux/redhat.html b/templates/pages/download/linux/redhat.html
index c4d3d9e..5c6dd5f 100644
--- a/templates/pages/download/linux/redhat.html
+++ b/templates/pages/download/linux/redhat.html
@@ -56,13 +56,13 @@ using Fedora for server deployments.
 To use the PostgreSQL Yum Repository, follow these steps:
 </p>
 <ol>
-  <li>Select version: <select id="version" class="custom-select" onChange="verChanged()"></select><br/></li>
-  <li>Select platform: <select id="platform" class="custom-select" onChange="platChanged()"></select></li>
-  <li>Select architecture: <select id="arch" class="custom-select" onChange="archChanged()"></select></li>
+  <li>Select version: <select id="version" class="custom-select"></select><br/></li>
+  <li>Select platform: <select id="platform" class="custom-select"></select></li>
+  <li>Select architecture: <select id="arch" class="custom-select"></select></li>
   <li>Copy, paste and run the relevant parts of the setup script:
     <div class="pg-script-container">
         <pre id="script-box" class="code"></pre>
-        <button id="copy-btn" class="pg-script-copy-btn" onclick="copyScript(this, 'script-box')">Copy Script</button>
+        <button id="copy-btn" class="pg-script-copy-btn">Copy Script</button>
     </div>
   </li>
 </ol>
diff --git a/templates/pages/download/linux/ubuntu.html b/templates/pages/download/linux/ubuntu.html
index 0465045..d1adfc6 100644
--- a/templates/pages/download/linux/ubuntu.html
+++ b/templates/pages/download/linux/ubuntu.html
@@ -1,5 +1,8 @@
 {%extends "base/page.html"%}
 {%block title%}Linux downloads (Ubuntu){%endblock%}
+{%block extrahead%}
+<script type="text/javascript" src="/download/js/apt.js?{{gitrev}}"></script>
+{%endblock%}
 {%block contents%}
 
 <h1>Linux downloads (Ubuntu) <img class="logo" src="/media/img/ubuntu.svg" alt="Ubuntu Logo" /></h1>
@@ -54,7 +57,7 @@ sudo apt-get update
 # Install the latest version of PostgreSQL.
 # If you want a specific version, use 'postgresql-12' or similar instead of 'postgresql':
 sudo apt-get install postgresql</pre>
-    <button class="pg-script-copy-btn" onclick="copyScript(this, 'script-box')">Copy Script</button>
+    <button id="copy-btn" class="pg-script-copy-btn">Copy Script</button>
 </div>
 
 <p>
