// TO SWITCH BETWEEN STATUSES FROM ONLINE TO OFFLINE document.addEventListener('DOMContentLoaded', function () { document.getElementById('goOnlineButton').addEventListener('click', function () { var xhr = new XMLHttpRequest(); xhr.open('GET', "{% url 'go_online' %}", true); xhr.onload = function () { if (xhr.status === 200) { // If the request is successful, reload the top window window.top.location.reload(); } else { console.log("You are still offline.") } }; xhr.send(); }); });