Script: Disable Right Click Context Menu

This article will help you add code to a specific screen or an entire survey to disable the right click context menu


Background

You may want to stop the ability for a respondent to access the Context Menu when you right click on a screen.

  • Examples of why you would need to do this are: 
    • You have new concept images in your survey that are not for public release
    • Depending on the browser this may also have access to the print function


Disable Right Click Context Menu (Entire Survey)

  1. Access the Survey Authoring Tool (SAT) 
  2. Access the 'DEFAULT TEXT' 
  3. Click on the HTML Editor icon tied to the 'SURVEY HEADER' 
  4. Access the Source Code Editor (</>)
  5. While in the Source Code Editor, add the following code
    <script type="text/javascript">
     /*DISABLE RIGHT CLICK FOR THIS PAGE*/
     
     if (typeof cmSurvey !== 'undefined')
     {
     if (typeof cmSurvey.plugins === 'undefined')
     {
     cmSurvey.plugins = {};
     }
     (function($)
     {
     cmSurvey.plugins.stopRightClick = function(questionNames, config)
     {
     $("body").attr("oncontextmenu", "return false");
     };
     })(jQuery);
     }
     
     cmSurvey.onPageLoad(function()
     {
     cmSurvey.plugins.stopRightClick([],
     {});
     
     });
     
     </script>
    	
  6. Don't forget to test

Disable the Menu on Specific Screens

You can also set this up for just one specific screen if needed

  1. Open one of the question cards for the specific screen you want this to happen on
  2. Access the HTML Editor for any of the fields available. The best ones to use would be the question text or the instruction text (if applicable). 
  3. Next follow steps 4 through 6 above
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us