• 在界面上的一些禁用操作,禁用页面后退、复制、粘贴等


    1.禁用Enter键表单自动提交

     1 document.onkeydown = function(event) {  
     2     var target, code, tag;  
     3     if (!event) {  
     4         event = window.event; //针对ie浏览器  
     5         target = event.srcElement;  
     6         code = event.keyCode;  
     7         if (code == 13) {  
     8             tag = target.tagName;  
     9             if (tag == "TEXTAREA") { return true; }  
    10             else { return false; }  
    11         }  
    12     }  
    13     else {  
    14        target = event.target; //针对遵循w3c标准的浏览器,如Firefox  
    15         code = event.keyCode;  
    16         if (code == 13) {  
    17             tag = target.tagName;  
    18             if (tag == "INPUT") { return false; }  
    19             else { return true; }  
    20         }  
    21     }  
    22 }; 

    2.防止页面后退

    1 history.pushState(null, null, document.URL);
    2 window.addEventListener('popstate', function () {
    3        history.pushState(null, null, document.URL);
    4 });

    3.禁止鼠标拖动

    1 document.ondragstart=function(){
    2     return false;
    3 }

    4.禁止鼠标右键菜单

    1 document.onselectstart = function(){
    2     return false;
    3 }

    5.禁止鼠标复制

    1 document.oncopy = function(){
    2     return false;
    3 }

    6.禁止键盘复制、粘贴

     1 document.onkeydown = function(){
     2     if(event.ctrlKey){
     3         return false;
     4     }
     5     if(event.altlKey){
     6         return false;
     7     }
     8     /* if(event.shiftKey){//email与登录需要
     9         return false;
    10     }  */
    11 } 
  • 相关阅读:
    迷宫的最短路径(bfs)
    INNODB引擎概述
    mysql-innodb的事务日志
    python-set集合
    一个python代码练习
    关于arm 的字节对齐
    学习嵌入式为什么要有uboot(深度解析)
    uboot 添加 自定义命令
    关于UBOOT,LINUX内核编译,根文件系统的15个小问题
    s5p6818 Overview
  • 原文地址:https://www.cnblogs.com/oolnc/p/7691175.html
Copyright © 2020-2023  润新知