zoukankan      html  css  js  c++  java
  • HTML页面 用CSS实现禁止选中、复制和右键

    最近在写页面的时候,需要在左上角加一个logo,但是复制的时候会把这张图片一块选中。

    那么我们可以通过css给它设置禁止选中,代码如下:

    .icon {
    -webkit-touch-callout: none; /* iOS Safari */
    -webkit-user-select: none; /* Chrome/Safari/Opera */
    -khtml-user-select: none; /* Konqueror */
    -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* Internet Explorer/Edge */
    user-select: none; /* Non-prefixed version, currently not supported by any browser */
    }

    添加禁止代码后,该图片就不能被选中了。

    豌豆资源搜索网站https://55wd.com 广州vi设计公司http://www.maiqicn.com

    html页面内容禁止选择、复制、右键

    刚才在一个站点的源代码的的时候发现的,其实原来真的很简单

    <body leftmargin=topmargin=oncontextmenu='return false' ondragstart='return false' onselectstart ='return false' onselect='document.selection.empty()' oncopy='document.selection.empty()' onbeforecopy='return false' onmouseup='document.selection.empty()'>

    关键就在  

    oncontextmenu='return false'
    ondragstart='return false' 
    onselectstart ='return false' 
    onselect='document.selection.empty()' 
    oncopy='document.selection.empty()' 
    onbeforecopy='return false' 
    onmouseup='document.selection.empty()'

    一个更简单的方法就是在<body>中加入如下的代码,这样鼠标的左右键都失效了。

    topmargin="0" oncontextmenu="return false" ondragstart="return false" onselectstart ="return false" onselect="document.selection.empty()" oncopy="document.selection.empty()" onbeforecopy="return false" onmouseup="document.selection.empty()"

    1、禁止网页另存为:在<body>后面加入以下代码: 

    <noscript> 
    <iframe src="*.htm"></iframe> 
    </noscript>

    2、禁止网页内容复制.粘贴:在<body>中加入以下代码: 

    <body onmousemove=/HideMenu()/ oncontextmenu="return false" ondragstart="return false" onselectstart ="return false" onselect="document.selection.empty()" oncopy="document.selection.empty()" onbeforecopy="return false" onmouseup="document.selection.empty()">
  • 相关阅读:
    名字空间,L,E, G , B 作用域, 内置电池
    lambda表达式
    表达式与声明的区别。
    jupyter book的使用
    centos7一键安装cacti_1.2.16版本
    docker修改阿里云镜像加速器
    centos单网卡多ip,被动模式
    centos同步时间
    centos7.x制作bond
    centos 6.X制作bond
  • 原文地址:https://www.cnblogs.com/qianxiaox/p/13735343.html
Copyright © 2011-2022 走看看