Javascript 如何在plone 4.1中禁用复制/粘贴或从文件预览下载文件?
我已经在门户下注册了javascript,使用的答案是 我遵循的步骤:1>将脚本复制到文件中Javascript 如何在plone 4.1中禁用复制/粘贴或从文件预览下载文件?,javascript,python,plone,Javascript,Python,Plone,我已经在门户下注册了javascript,使用的答案是 我遵循的步骤:1>将脚本复制到文件中 document.onkeydown = function(e) { if (e.ctrlKey && e.keyCode === 65) { // alert('not allowed'); return false; } if (e.ctrlKey && e.keyCode === 67) { //
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)选择的门户_javascripts/在开发模式下使用相同的id/url添加了此脚本并保存。
3.在atreal.richfile.preview中,通过将SelectStart和SelectDrag上的鼠标按钮事件设置为False,自定义模板(atreal.richfile.preview.interfaces.ipreview atreal.richfile.preview.viewlet)。通过删除预览窗口的右上角按钮并在此窗口中显示除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>
预览
draggable=“false”onselectstart=“false”
尝试此操作以防止出现默认行为
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>
看看这里,请先在空白处单击以选择窗口,然后继续。您确实可以看到示例中的代码正在工作。也许,你是在复制剧本。您包括jQuery库了吗。以上需要jQuery才能运行。“return false”应该用于上述javascript中检查的3个键代码中的每一个,以便正确工作。编辑了上面的脚本