使用JQuery禁用文本框的剪切、复制、粘贴功能

来源:互联网 发布:冒险岛怪物数据库 编辑:程序博客网 时间:2024/05/01 22:09
<span style="font-size:14px;"><!DOCTYPE html><html>    <head>        <title>JQuery禁用文本框的剪切、复制、粘贴功能演示代码</title>        <style>            .main {                width: 900px;                margin: 0 auto;                height: 900px;                border: 1px solid #ccc;                padding: 20px;            }            .header{                height: 100px;             }            .content{                 height: 700px;                border-top: 1px solid #ccc;                padding-top: 15px;            }            .footer{                height: 100px;                bottom: 0px;            }            .heading{                color: #FF5B5B;                margin: 10px 0;                padding: 10px 0;                font-family: trebuchet ms;            }            /*downloaded from http://www.uncletoo.com*/        </style>    </head>    <body>        <div class="main">            <div class="header"><a title="UncleToo中文网" href="http://www.uncletoo.com/"><img alt="UncleToo中文网" src="http://www.uncletoo.com/theme/default/images/logo.png"></a>            </div>            <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">            </script>            <script>                $(document).ready(function() {                    $(document).ready(function() {                        $('#txt_input').bind("cut copy paste", function(e) {                            alert('Copy Paste is disabled');                            e.preventDefault();                        });                        $('#textarea_inp').bind("cut copy paste", function(e) {                            alert('Copy Paste is disabled');                            e.preventDefault();                        });                        $('#div_cnt').bind("cut copy paste", function(e) {                            alert('Copy Paste is disabled');                            e.preventDefault();                        });                    });                });            </script>            <div class="content">                <div class="heading">                    JQuery禁用文本框的剪切、复制、粘贴功能演示                </div>                <div id='dv1'>                    <table>                        <tr><td>姓名</td><td><input type='text' id='txt_input' /></td></tr>                        <tr><td>简介</td><td> <textarea id='textarea_inp'></textarea></td></tr>                        <tr><td>Div Content</td><td><div id='div_cnt'>在上面文本框中执行复制、粘贴试试吧!!</div></td></tr>                    </table>                </div>                <script>                    (function(i, s, o, g, r, a, m) {                        i['GoogleAnalyticsObject'] = r;                        i[r] = i[r] || function() {                            (i[r].q = i[r].q || []).push(arguments)                        }, i[r].l = 1 * new Date();                        a = s.createElement(o),                                m = s.getElementsByTagName(o)[0];                        a.async = 1;                        a.src = g;                        m.parentNode.insertBefore(a, m)                    })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');                    ga('create', 'UA-43091346-1', 'www.uncletoo.com');                    ga('send', 'pageview');                </script>                </body>                </html></span>

0 0