Ever wanted to stop your students from printing out a quiz while they were taking it? This simple script will stop them from doing so. Keep in mind that this only works while a student is in a quiz, it does not work once students have completed the quiz and are viewing their results.
You also must insert this at the beginning of a question that will appear on the quiz, so if it is inside a question in a question set, it may or may not work. The best practice is to have a question one that always appears on the quiz, and contains the code. It only needs to appear in one question on the quiz to work for the entire quiz.
Simply copy and paste the below text into the 'Text' portion of any one question on a quiz and the student will be unable to utilize the right-click button on their mouse.
<STYLE media="print">BODY {display:none}</STYLE>
<BODY ondragstart="return false" onselectstart="return false">
<script language=JavaScript>
<!--
var message="Function Disabled!";
//
function clickIE() {if (document.all) {alert(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {alert(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")
// -->
</script>