Mouse Leaving the window alert Pop-Up--Moodle <p>I have developed an online exam using the Moodle software which is written in PHP. Now I want to restrict the person who is taking the test without being able to navigate to other tabs or other windows by generating a mouserover pop-up.</p> <p>Following is the I have a code for the alert pop-up when the user leaves the window:</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript"&gt; function addEvent(obj, evt, fn) { if (obj.addEventListener) { obj.addEventListener(evt, fn, false); } else if (obj.attachEvent) { obj.attachEvent("on" + evt, fn); } } addEvent(window,"load",function (e) { addEvent(document, "mouseout", function (e) { e = e ? e : window.event; var from = e.relatedTarget || e.toElement; if (!from || from.nodeName == "HTML") { // stop your drag event here // for now we can just use an alert alert("Your Test will close in 10 secs unless you return to the page "); } }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt;&lt;/body&gt; &lt;/html&gt;</code></pre> </div> </div> </p> <p>Is there a possibility to restrict the user with this code and in that case where to append this code to the moodle's actual source code??</p> <p>Thanks.</p>