title: Detect click in iframe (React.js)
body: <p>I have an iframe, and I want to prevent people from downloading the contents. I have already used #toolbar=0, but a user can still right-click to download. I know it's impossible to completely prevent downloads, but I'm just looking for a solution to prevent easy downloads for the basic user.</p>
  <p>I have tried overlaying the iframe with a transparent image to block the right-click, but that makes it impossible to scroll through the document.</p>
  <p><strong>The goal right now</strong>: detect a right-click <em><strong>in the iframe</strong></em>, and disable the context menu.</p>
  <p>The code that I have right now is:</p>
  <pre><code>componentDidMount(){
   document.getElementById('myIframe').addEventListener(&quot;click&quot;,this.handleClick);
  }
  componentWillUnmount(){
   document.getElementById(&quot;myIframe&quot;).removeEventListener(&quot;click&quot;, this.handleClick);
  }
  
  render(){
    return(
       &lt;div className=&quot;PDFs&quot;&gt;
         &lt;iframe id=&quot;myIframe&quot; src={PDF + &quot;#toolbar=0&quot;} width=&quot;100%&quot; height=&quot;800px&quot; className=&quot;Viewer&quot;/&gt; 
       &lt;/div&gt;
    );
  }
  </code></pre>
  <p>But it only works if your mouse is on the exact line of pixels that outlines the iframe. Not very useful.</p>
  <p><strong>If you can find any way to prevent the downloading of a PDF without converting the PDF to anything and without blocking scrolling access to the PDF, I'll take it.</strong></p>
  <p>Some more info: the page that this will be displayed on will only show this viewer and nothing else. If I can disable the context menu for this entire page, that would be brilliant.</p>
  <p>I have also already tried using &quot;onClickDown&quot; and &quot;onContextMenu&quot; and neither of them worked, unless I was using it wrong.</p>