{"id":73,"date":"2012-02-11T13:41:25","date_gmt":"2012-02-11T05:41:25","guid":{"rendered":"https:\/\/blog.indeex.club\/?p=73"},"modified":"2020-06-20T22:46:53","modified_gmt":"2020-06-20T14:46:53","slug":"javascript-%e5%b1%8f%e8%94%bd%e5%8f%b3%e9%94%ae%e5%8a%9f%e8%83%bd","status":"publish","type":"post","link":"https:\/\/blog.indeex.club\/index.php\/2012\/02\/11\/javascript-%e5%b1%8f%e8%94%bd%e5%8f%b3%e9%94%ae%e5%8a%9f%e8%83%bd\/","title":{"rendered":"Javascript \u5c4f\u853d\u53f3\u952e\u529f\u80fd"},"content":{"rendered":"<p>\u7a81\u7136\u60f3\u8981\u7981\u6b62\u6293\u5c4f\u3001\u590d\u5236\u3001\u6253\u5370\uff0c\u590d\u5236\u3001\u6253\u5370\u53ef\u80fd\u987a\u624b\u4e00\u70b9\u7f51\u4e0a\u5404\u79cd\u5404\u6837\u7684\u811a\u672c\u4fef\u9996\u7686\u662f\u3002\u4f46\u6293\u5c4f\u600e\u4e48\u7981\u6b62\uff1fPrintScreen\u662f\u4e00\u4e2a\u7279\u6b8a\u7684\u952e\uff0c\u5b83\u662f\u6ca1\u6709keyCode\u7684\u952e\uff0c\u6240\u4ee5onkeydown\u53d8\u5f97\u6beb\u65e0\u7528\u5904\u3002\u4e0d\u8fc7\u6362\u4e00\u79cd\u601d\u8def\u7684\u8bdd\u53ef\u4f1a\u66f4\u597d\uff0c\u6211\u4eec\u4ece\u7c98\u8d34\u677f\u7740\u624b\u91c7\u53d6\u66f2\u7ebf\u6551\u56fd\u7b56\u7565\u3002\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-javascript line-numbers\">&lt;script language=\"javascript\"&gt; \n\nwindow.setInterval(\"clipboardData.setData('text','')\",100); \n\n&lt;\/script&gt; \n<\/code><\/pre>\n<p>\u4ee5\u4e0a\u4ee3\u7801\u662f\u6bcf100\u6beb\u79d2\u6e05\u7a7a\u4e00\u6b21\u7c98\u8d34\u677f\u64cd\u4f5c\u3002\u5f53\u9875\u9762\u52a0\u8f7d\u65f6\u811a\u672c\u7a0b\u5e8f\u5c31\u5f00\u59cb\u81ea\u52a8\u6267\u884c\u3002\u4f46\u8fd9\u6837\u6709\u4e2a\u5f0a\u7aef\uff0c\u4e0d\u7ba1\u7f51\u9875\u88ab\u6700\u5c0f\u5316\u8fd8\u662f\u600e\u4e48\u7684\u53ea\u8981\u8fd9\u4e2a\u7a97\u53e3\u5f00\u7740\u6211\u4eec\u7535\u8111\u6240\u6709\u7684\u590d\u5236\u64cd\u4f5c\u90fd\u65e0\u6cd5\u8fdb\u884c(\u811a\u672c\u4e00\u76f4\u5728\u6e05\u7a7a\u7c98\u8d34\u677f)\uff0c\u4ece\u67d0\u79cd\u610f\u4e49\u4e0a\u8bb2\u662f\u8fbe\u5230\u9884\u671f\u6548\u679c\u4e86\uff0c\u4f46\u6709\u4e9b\u6b20\u4f73:(\u3002<\/p>\n<p>\u6211\u4eec\u77e5\u9053\u6240\u6709\u7684\u63a7\u4ef6\u90fd\u6709onfocus\u548conblur\u4e8b\u4ef6\uff0cwindow\u7a97\u53e3\u4e5f\u4e0d\u4f8b\u5916\u3002\u6211\u4eec\u901a\u8fc7\u5229\u7528\u8fd9\u4e24\u4e2a\u4e8b\u4ef6\uff0c\u53ea\u6709\u5728\u5f53\u524d\u7a97\u53e3\u5904\u4e8e\u6d3b\u52a8\u72b6\u6001\u65f6\u624d\u6267\u884c\u6e05\u7a7a\u64cd\u4f5c\uff0c\u5426\u5219\u505c\u6b62\u6267\u884c\u3002\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"line-numbers\">&lt;script language=\"javascript\"&gt; \n\nvar interval \n\nwindow.onfocus=function(){interval=window.setInterval(\"clipboardData.setData('text','')\",100);} \n\nwindow.onblur=function(){window.clearInterval(interval);} \n\n&lt;\/script&gt; \n<\/code><\/pre>\n<p>\u8fd9\u6837\u5c31\u53ef\u4ee5\u5b8c\u7f8e\u7684\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u3002\u4f46\u5bf9\u4e8e\u4e0d\u5c06\u622a\u5c4f\u5185\u5bb9\u653e\u5165\u7c98\u8d34\u677f\u7684\u622a\u5c4f\u7a0b\u5e8f\u6765\u8bf4\u6b64\u65b9\u6cd5\u8fd8\u662f\u5fc3\u6709\u4f59\u800c\u529b\u4e0d\u8db3\u7684\u3002<\/p>\n<p>\u6700\u65b0\u6d4b\u8bd5\u5b9e\u8df5\u53d1\u73b0\u4f7f\u7528onfocus\u548conblur\u4e8b\u4ef6\u7684\u65b9\u6cd5\u4e5f\u4e0d\u5c3d\u5982\u4eba\u610f\uff0c\u5f53\u7126\u70b9\u6307\u5411\u7a0b\u5e8f\u9875\u9762\u5185\u5176\u4ed6\u63a7\u4ef6\uff08\u5373\u4f7fTable\uff09\u65f6\uff0cwindow\u5c06\u5931\u53bb\u7126\u70b9\u4ece\u800c\u89e6\u53d1onblur\u4e8b\u4ef6\u505c\u6b62\u6267\u884c\u6e05\u7a7a\u7c98\u8d34\u677f\u547d\u4ee4\uff0c\u96be\u9053\u9700\u8981\u904d\u5386\u6240\u6709\u63a7\u4ef6\u4e3a\u5176onfocus\u548conblur\u7ed1\u5b9a\u4e8b\u4ef6\uff1f\u6709\u4e9b\u8ff7\u832b\u4e0e\u5931\u671b\u3002<\/p>\n<p>\u53e6window.onfocus\u53ea\u662fdocument\u7684onfocus\uff0c\u5982\u679c\u7126\u70b9\u5728\u5730\u5740\u680f\u6216\u83dc\u5355\u4e4b\u7c7b\u7684\u5730\u65b9onfocus\u4e5f\u5c06\u5931\u6548\u3002<\/p>\n<p>\u4ec5\u4ee5\u6b64\u6587\u5b57\u8bb0\u5f55\u81ea\u5df1\u534a\u5929\u65f6\u95f4\u7814\u7a76JS\u7684\u5fc3\u5f97\u3002<\/p>\n<p>\u7981\u6b62\u6253\u5370\u53ea\u9700\u5c06\u5982\u679c\u4e0b\u6837\u5f0f\u4ee3\u7801\u653e\u5165\u7a0b\u5e8f\u5373\u53ef(\u6253\u5370\u51fa\u7684\u9875\u9762\u5185\u5bb9\u5c06\u4e3a\u7a7a\u767d)\uff1a<\/p>\n<pre><code class=\"line-numbers\">&lt;style&gt;@media print{body{display:none}}&lt;\/style&gt; \n<\/code><\/pre>\n<p>\u7981\u6b62\u590d\u5236\u3001\u9009\u62e9\u3001\u53f3\u952e\u83dc\u5355\uff1a<\/p>\n<pre><code class=\"line-numbers\">&lt;script language=javascript&gt; \n\nfunction click() { \n\nreturn false;} \n\nfunction click1(){if (event.button==2) {return false; }} \n\nfunction CtrlKeyDown(){ \n\nif (event.keyCode==67&amp;&amp;event.ctrlKey) \n\n{ \n\nclipboardData.setData('text',''); \n\nreturn false;  \n\n} \n\n} \n\ndocument.onkeydown=CtrlKeyDown; \n\ndocument.onselectstart=click; \n\ndocument.onmousedown=click1; \n\n&lt;\/script&gt; \n\n&lt;noscript&gt;&lt;iframe src=*.html&gt;&lt;\/iframe&gt;&lt;\/noscript&gt; \n\n&lt;script language=javascript&gt;  \n\n&lt;!--  \n\nif (window.Event)  \n\ndocument.captureEvents(Event.MOUSEUP);  \n\nfunction nocontextmenu(){  \n\nevent.cancelBubble = true  \n\nevent.returnValue = false;  \n\nreturn false;  \n\n}  \n\nfunction norightclick(e){  \n\nif (window.Event){ \n\nif (e.which == 2 || e.which == 3) \n\nreturn false; \n\n}  \n\nelse if (event.button == 2 || event.button == 3) \n\n{ \n\nevent.cancelBubble = true; \n\nevent.returnValue = false;return false;}  \n\n}  \n\ndocument.oncontextmenu = nocontextmenu; \/\/ for IE5+  \n\ndocument.onmousedown = norightclick; \/\/ for all others  \n\n\/\/--&gt;&lt;\/script&gt; \n<\/code><\/pre>\n<p>\u4ee5\u4e0a\u4ee3\u7801\u5728IE6.0\u73af\u5883\u8fd0\u884c\u6b63\u5e38\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7a81\u7136\u60f3\u8981\u7981\u6b62\u6293\u5c4f\u3001\u590d\u5236\u3001\u6253\u5370\uff0c\u590d\u5236\u3001\u6253\u5370\u53ef\u80fd\u987a\u624b\u4e00\u70b9\u7f51\u4e0a\u5404\u79cd\u5404\u6837\u7684\u811a\u672c\u4fef\u9996\u7686\u662f\u3002\u4f46\u6293\u5c4f\u600e\u4e48\u7981\u6b62\uff1fPr<a href=\"https:\/\/blog.indeex.club\/index.php\/2012\/02\/11\/javascript-%e5%b1%8f%e8%94%bd%e5%8f%b3%e9%94%ae%e5%8a%9f%e8%83%bd\/\" class=\"read-more\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[4],"_links":{"self":[{"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/posts\/73"}],"collection":[{"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/comments?post=73"}],"version-history":[{"count":1,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/posts\/73\/revisions"}],"predecessor-version":[{"id":82,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/posts\/73\/revisions\/82"}],"wp:attachment":[{"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/media?parent=73"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/categories?post=73"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/tags?post=73"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}