Skip To Main Content
Skip To Main Content

Preventing right clicking and printing of WebCT multiple choice quizzes/assessments

Note: This code will only work with Multiple Choice questions. If you use it on a test that involves typing into short answer or paragraph text boxes, the students won't be able to.

To prevent students from right clicking on an assessment page and printing questions and answers, copy and paste the following Javascript code into the Custom Instructions text box with the Edit Properties page of an assessment.

From your course home page, you would click on the Assessment link on the left.  Find the quiz/exam/test/assessment you wish to add the Javascript code to. Click the ActionsLink drop down menu to the right of it and select "Edit Properties." Scrollto the bottom of the screen and expand the heading "Custom Instructions." Copy and paste the Javascript code into the large text entry box directly under the Custom Instructions heading. Be sure to check off the "Use HTML" box below the text entry box, or this will not work to prevent right clicking. If you are displaying each question on a separate page, be sure to also check off the box next to "Display custom assessment instructions on every question when questions are delivered one at  a time. Click Save at the bottom of the screen when you are finished. You can click the Actions Link drop down menu and choose to Preview the quiz to check to see if the code is indeed preventing right clicking and printing.

Copy and Paste code below:

<HEAD>
<META HTTP-EQUIV="imagetoolbar" CONTENT="no">
</HEAD>

<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) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==1||e.which==2||e.which==3) {(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")

function disableselect(e){
return false
}
function reEnable(){
return true
}
document.onselectstart=new Function ("return false")
if (window.sidebar){
document.onmousedown=disableselect
document.onclick=reEnable}
</script>