Frequently asked question
Yes, it is possible to disable the ability to right-click a web app configured using ArcGIS API for JavaScript. Administrators and developers may want to disable right-clicking, for example, to prevent users from viewing the back-end source code when viewing web maps in a supported web browser. This raises security concerns, as sensitive data may be involved in the creation of the web map (such as picture files.)
The example screenshot below is taken from Google Chrome. In general, users can right-click anywhere on the page and select View page source.
To counter the problem, the oncontextmenu property must be added and set to return false to the <body> tag of the JavaScript file as follows:
... <body oncontextmenu="return false"> <div id="viewDiv"></div> </body> ...
Note: Upon adding the above code snippet, any context menu created to allow edits is now unavailable.
The following image is an example of how the <body> tag looks in a script.
Get help from ArcGIS experts
Download the Esri Support App