Home Web Front-end JS Tutorial JSCode all of Brower Globally shields the right-click function of web pages. Specific implementation_javascript skills

JSCode all of Brower Globally shields the right-click function of web pages. Specific implementation_javascript skills

May 16, 2016 pm 05:32 PM
Right click shield Web page

[javascript]

复制代码 代码如下:

<script type="text/javascript">
function clickIE4(){
        if (event.button==2){
                return false;
        }
}

function clickNS4(e){
        if (document.layers||document.getElementById&&!document.all){
                if (e.which==2||e.which==3){
                        return false;
                }
        }
}

function OnDeny(){
        if(event.ctrlKey || event.keyCode==78 && event.ctrlKey || event.altKey || event.altKey && event.keyCode==115){
                return false;
        }
}

if (document.layers){
        document.captureEvents(Event.MOUSEDOWN);
        document.onmousedown=clickNS4;
        document.onkeydown=OnDeny();
}else if (document.all&&!document.getElementById){
        document.onmousedown=clickIE4;
        document.onkeydown=OnDeny();
}

document.oncontextmenu=new Function("return false");
</script>

<script type="text/javascript">
function clickIE4(){
        if (event.button==2){
                return false;
        }
}

function clickNS4(e){
        if (document.layers||document.getElementById&&!document.all){
                if (e.which==2||e.which==3){
                        return false;
                }
        }
}

function OnDeny(){
        if(event.ctrlKey || event.keyCode==78 && event.ctrlKey || event.altKey || event.altKey && event.keyCode==115){
                return false;
        }
}

if (document.layers){
        document.captureEvents(Event.MOUSEDOWN);
        document.onmousedown=clickNS4;
        document.onkeydown=OnDeny();
}else if (document.all&&!document.getElementById){
        document.onmousedown=clickIE4;
        document.onkeydown=OnDeny();
}

document.oncontextmenu=new Function("return false");
</script>

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to open the right-click menu through shortcut keys How to open the right-click menu through shortcut keys Jan 14, 2024 pm 03:12 PM

How to open the right-click menu through shortcut keys

How to send web pages to desktop as shortcut in Edge browser? How to send web pages to desktop as shortcut in Edge browser? Mar 14, 2024 pm 05:22 PM

How to send web pages to desktop as shortcut in Edge browser?

Right click not working in Word or PowerPoint [FIXED] Right click not working in Word or PowerPoint [FIXED] Feb 27, 2024 pm 02:19 PM

Right click not working in Word or PowerPoint [FIXED]

Win10 right click does not run as administrator Win10 right click does not run as administrator Jan 06, 2024 pm 10:29 PM

Win10 right click does not run as administrator

How to set up text message blocking on iPhone How to set up text message blocking on iPhone Feb 24, 2024 pm 01:48 PM

How to set up text message blocking on iPhone

Possible reasons why the network connection is normal but the browser cannot access the web page Possible reasons why the network connection is normal but the browser cannot access the web page Feb 19, 2024 pm 03:45 PM

Possible reasons why the network connection is normal but the browser cannot access the web page

How to set up web page automatic refresh How to set up web page automatic refresh Oct 26, 2023 am 10:52 AM

How to set up web page automatic refresh

NVIDIA Control Panel right-click menu not found NVIDIA Control Panel right-click menu not found Jan 11, 2024 am 11:11 AM

NVIDIA Control Panel right-click menu not found

See all articles