DOM基本代码二

-------------------------------

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript">
        function modifyClipboard()
        {
            var txt = clipboardData.getData("text");
            txt = txt + " 本文章来自于陈龙制作,文章来源:" + location.href;
            clipboardData.setData('text',txt);
        }
    </script>
</head>
<body onclose="alert('是否关闭?');return false;">
    <input type="button"value="点击"onclick="if(window.event.altKey)alert('alt键被按下')"/>
    <input type="button"value="点击"onclick="if(window.event.shiftKey)alert('shift键被按下')"/>
    <!--类似于上面的按钮判断的还有各种其他的-->
    <!--将window.event.returnValue = false 后就会阻止默认事件动作-->
    <a href="http://www.taobao.com" onclick="window.event.returnValue = false;">淘宝</a>
    <input type="button"value="分享给好友"onclick="clipboardData.setData('text', 'I find a quite well net page which is filled with AV' + location.href); alert('已经放到粘贴板上');"/>
    <table border="1">
        <tr>
            <td><label for="name">姓名:</label></td>
            <td><input type="text" id="name"/></td>
        </tr>
        <tr>
            <td><label for="pass1">手机号</label></td>
            <td><input type="text" id="pass1" onpaste="alert('禁止粘贴'); return false;"/></td>
        </tr>
        <tr>
            <td><label for="pass2">重复手机号</label></td>
            <td><input type="text" id="pass2" onpaste="alert('禁止粘贴'); return false;" /></td>
        </tr>
    </table>
    <textarea oncopy="alert('禁止复制'); return false;"onpaste="alert('禁止粘贴'); return false;">
    这里是文章的内容,复制这里吧!
    </textarea>
    
    <!--oncopy 和onpaste两种事件适合任何文本框,是在复制粘贴时对应的事情-->
    <!--不能再oncopy事件上修改粘贴板,需等待少许事件,0.1秒之类的-->
    <br/>
    <textarea oncopy="setTimeout('modifyClipboard()',100)">
        试试复制的时候要加上我的内容的方法吧!
    </textarea>
    <a href=" htmlpagedom.html" onclick="window.event.returnValue=false">htmlpagedom.html</a>

    
</body>
</html>
What I don't dare to say is I can't!
原文地址:https://www.cnblogs.com/sytu/p/4085719.html