javascript - How to disable copy/paste or download a file from a file preview in plone 4.1? -


i have registered javascript under portal_javascript using answer 1 how disable copy paste (browser) steps followed: 1> copied script in file

document.onkeydown = function(e) { if (e.ctrlkey && e.keycode === 65) { // alert('not allowed'); return false; } if (e.ctrlkey && e.keycode === 67) { // alert('not allowed'); return false; } if (e.ctrlkey && e.keycode === 86) { // alert('not allowed'); return false; } };​ document.oncontextmenu=new function("return false") 

step 2)selected portal_javascripts /added script same id/url under development mode , saved. 3.in atreal.richfile.preview customize template (atreal.richfile.preview.interfaces.ipreview-atreal.richfile.preview.viewlet) setting mouse buttons events onselectstart , onselectdrag false. change code removing right top buttons of preview window , displaying files other pdf in window. use code block :

<dl class="richfile portlet" tal:condition="view/available" tal:attributes="id view/plugin_id" i18n:domain="atreal.richfile.preview"> <dt tal:attributes="id string:${view/plugin_id}header" class="rfheader portletheader"> <span class="portlettopleft"></span> <!--tal:block tal:replace="structure view/controls"--> <span class="title" style="font-weight:bold" i18n:translate=""> preview </span> <span class="portlettopright" ></span> </dt> <!--your specific code here tal:condition="not:ispdf" --> <dd> <tal:block define="ispdf python:here.absolute_url().endswith('.pdf')"> <iframe src="http://www.xyz.com" tal:condition="not:ispdf" tal:attributes="src string:${here/absolute_url}/rfpreview" width="100%" height="400" scrolling="auto" frameborder="1"> draggable="false" onselectstart="false" </iframe> </tal:block> </dd> </dl> 
  1. in zmi, portal_types/file select aliases tab , change methods (selected layout) both default , view aliases , save.
  2. in zmi, portal_skins/archetypes customize at_download code return nothing or rather deleted code there.
  3. use add-on collective.documentviewer preview pdf files. works fine me. have been persueing problem past 1 1/2 month. happy end result. thought of sharing all. :)

try prevent default behaviour.

document.onkeydown = function(e) { if (e.ctrlkey && e.keycode === 65) { alert('not allowed'); } if (e.ctrlkey && e.keycode === 67) { alert('not allowed'); } if (e.ctrlkey && e.keycode === 86) { alert('not allowed'); } return false; };​ 

*demo* test on result window, not anywhere else.

update disable right-click

<script type="text/javascript"> <!-- //disable right click script //visit http://www.rainbow.arch.scriptmania.com/scripts/ var message="sorry, right-click has been disabled"; /////////////////////////////////// function clickie() {if (document.all) {(message);return false;}} function clickns(e) {if (document.layers||(document.getelementbyid&&!document.all)) { if (e.which==2||e.which==3) {(message);return false;}}} if (document.layers) {document.captureevents(event.mousedown);document.onmousedown=clickns;} else{document.onmouseup=clickns;document.oncontextmenu=clickie;} document.oncontextmenu=new function("return false") // --> </script> 

Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -