Completed

Angular 7: Disable right-click and highlight on <object> element without disabling scrolling

I have an <object> element (see below) into which a PDF is being loaded. Currently, users can simply right-click on it and download it in Chrome. Firefox even shows a download button.

I want to prevent users from downloading the PDF, so I want to disable right-click, and I also want to prevent them from highlighting and copying the text. And since <object> elements don't respond to click events, I am handling the click event in the <div> below it with (contextmenu)= "myFunction()".

The problem is that disabling right-click in this way also disables scrolling for some reason. So does style="pointer-events: none". I need to disable right-clicks and highlighting on the PDF but the user still needs to be able to scroll to view the pages below.

I am using Angular 7 so this is being done with HTML and Typescript. The PDF file is coming from Firebase Storage.

<object width="100%" height="690" type="application/pdf" [data]="([login to view URL])">

<div style="position:absolute; top:0; left:0; bottom:0; right:0;" (contextmenu)="onRightClick($event)"></div>

Skills: CSS, HTML5, PDF, Typescript

See more: disable right click mouse globally vba, disable right click flv, vb6 webbrowser disable right click, angular 4 stoppropagation, angular 5 stoppropagation, angular 4 stop event propagation, angular 2 stoppropagation not working, event.stoppropagation is not a function angular 2, how can i prevent text/element selection with cursor drag, event stoppropagation angular 4, angular 6 stop event propagation, vb6 disable right click mouse windows, disable right click javascript cartweaver, iframe disable right click iframe, disable right click iframe, disable right click actionscript, disable right click mouse windows, disable right click firefox iframe, webbrowser disable right click, html iframe disable right click

About the Employer:
( 1 review ) Antelope, United States

Project ID: #19243152

Awarded to:

WhiteHorse2019

Hello It's a piece of cake. I can help you to do it perfectly. If you hire me, i can start right now, and i will do my best for us. Thanks.

$30 USD in 1 day
(1 Review)
0.8

4 freelancers are bidding on average $27 for this job

BrokeProgrammer

Hi, I am Anshul, a Full Stack Developer with experience in technologies like Java, Angular, Node, React, etc. I have been working since last 4 years, started as an intern in a startup that ended up being one of t More

$20 USD in 1 day
(0 Reviews)
0.0
evonsystems7

"Hi, Hope you are doing well! Thanks for sharing your project requirement with us. It will be our great pleasure to work on your project. I have checked your requirement, yes we can do it, because we already work on si More

$34 USD in 7 days
(0 Reviews)
0.0
ALIATHERSE

Hi, I have reviewed your job requirements and I am interested in this project and can easily complete this job in minimum time possible with guaranteed results. I am an expert data entry specialist as well as a s More

$25 USD in 1 day
(0 Reviews)
0.0