Disable right click on Image in jQuery

Last Reply 8 months ago By dharmendr

Posted 8 months ago

hello,

i have a website where i have images i see people do right click on image and check the exact path of image i want to stop right click on my images so user cannot see the exact path of images. please advice

You are viewing reply posted by: dharmendr 8 months ago.
Posted 8 months ago Modified on 8 months ago

Hi nauna,

Refer below code.

HTML

<div id="dvDetails">
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script type="text/javascript">
        $('#dvDetails').on('contextmenu', 'img', function (e) {
            return false;
        });
    </script>
    <img src="https://i.imgur.com/6LLBMoM.jpg" alt="Alternate Text" />
</div>

Demo