1

I want to prevent copying content loaded in iframe. I am using the following code [per this answer], and it works fine.

<html>
<head>
    <title>Test</title>
    <script type='text/javascript' src='//code.jquery.com/jquery-1.8.3.js'></script>
    <script type='text/javascript'>
        $(window).load(function () {            
            var $frame = $("#tif");
            $frame.contents().bind("copy", function (e) {
                e.preventDefault();
            });
        });
    </script>
</head>
<body>
<iframe src="whatever.com" height="768" width="1366" id="tif"></iframe>
</body>
</html>

But when a pdf file is given as the source, the above code fails. Any suggestions?

0 Answers0