JS Disable right-click menu/Copy&Paste/Keyboard event

  • Last update:  2020-12-15
  • I. Disable right click

    After logging in to the system, the user can view the URL and then access it by clicking the properties on right-click menu. If you want to enhance security and restrict users from viewing the URL, you can disable right-click menu.

    Click Template>Template Web Attributes>Pagination preview , select "individually set for this template", add a "loading end" event using following JS:

    function nocontextmenu(event){
    event = event || window.event;
    if (event.which == 2 )
    event.returnValue = false;
    return false;
    }
    document.oncontextmenu = nocontextmenu;

    The basic principle of this code is to return false when the user's page event is the right click (event.which == 2), and the pop-up menu is disabled.

    If there is a parameter panel in the template, and you want to disable the right button as soon as the report is shown, instead of after querying, you need to add an initialization event to the query button of the parameter panel and write the above JavaScript code.

    Note: If you want to disable the right-click operation on data analysis preview or data entry preview, do the same settings in the template>template web attributes on corresponding preview page setting.


    II. Disable copy, paste and cut

    For disabling copy function, click Template>Template Web Attributes>Pagination preview , select "individually set for this template", add a "loading end" event using following JS:

    1.png

    document.oncopy=function(e) {  
       alert('Cannot copy currently!');  
       return false;  
    }

    For disabling other functions, please refer to the table below:

    Function
    Method
    Selection

    document.onselectstart  

    Copy

    document. oncopy

    Cut

    document. oncut  

    Paste

    document. onpaste  

    III. Disable keyboard events

    For monitoring user keyboard events by passing the event object, such as prohibiting the enter key function, click Template>Template Web Attributes>Pagination preview , select "individually set for this template", add a "loading end" event using following JS:

    2.png

    function test(event){
     if(event.keyCode == 13){
    alert("The enter key cannot be used!");
    return false;
    }else{
    return true;
    }
    }
    Document.onkeydown =test;

    For more keycode, please Google search ASCII.

    Attachment List


    Theme: Report Application
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy