0

我已经使用我遵循的如何禁用复制粘贴(浏览器)步骤中的答案 1 在 portal_javascript 下注册了 javascript :1> 将脚本复制到文件中

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")

步骤2)选择portal_javascripts /在开发模式下添加这个具有相同id / url的脚本并保存。3.在 atreal.richfile.preview 中自定义模板 (atreal.richfile.preview.interfaces.ipreview-atreal.richfile.preview.viewlet),将鼠标按钮事件 onSelectStart 和 onSelectDrag 设置为 False。通过删除预览窗口的右上角按钮并在此窗口中显示除 pdf 之外的文件来更改代码。将代码块用作:

<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. 在 ZMI 中,portal_types/File 选择 Aliases 选项卡并将 Default 和 View Aliases 的方法更改为(选定布局)并保存。
  2. 在 ZMI 中,portal_skins/archetypes 自定义 at_download 代码以不返回任何内容,或者删除那里的代码。
  3. 使用附加组件collective.documentviewer 预览pdf 文件。这对我来说很好。在过去的 1 1/2 个月里,我一直在研究这个问题。最后,我对最终结果感到满意。想和大家分享一下。:)
4

1 回答 1

2

试试这个以防止默认行为。

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;
};​

*演示* 在结果窗口上进行测试,而不是在其他任何地方。

更新禁用右键单击

<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> 
于 2012-07-07T08:21:13.207 回答