在阅读我的 RSS 源时,我偶然发现了MuyComputer上的一篇文章,这篇文章又引导我找到了 José Jesús Pérez Aguinaga 的一篇帖子,他在帖子中向我们展示了如何使用数据 URI格式,结合 HTML5 的强大功能和一个名为“ contenteditable ”的新元素,我们可以创建一个像记事本一样使用的 HTML 页面。
我们只需要在地址栏中输入:
data:text/html, <html contenteditable>
在José Jesús Pérez Aguinaga 的帖子中,评论里还出现了一些其他值得一看的例子:
data:text/html, <textarea style="font-size: 1.5em; width: 100%; height: 100%; border: none; outline: none" autofocus />
data:text/html, <html><head><link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'><style type="text/css"> html { font-family: "Open Sans" } * { -webkit-transition: all linear 1s; }</style><script>window.onload=function(){var e=false;var t=0;setInterval(function(){if(!e){t=Math.round(Math.max(0,t-Math.max(t/3,1)))}var n=(255-t*2).toString(16);document.body.style.backgroundColor="#ff"+n+""+n},1e3);var n=null;document.onkeydown=function(){t=Math.min(128,t+2);e=true;clearTimeout(n);n=setTimeout(function(){e=false},1500)}}</script></head><body contenteditable style="font-size:2rem;line-height:1.4;max-width:60rem;margin:0 auto;padding:4rem;">
data:text/html, <body contenteditable style="font-size:2rem;line-height:1.4;max-width:60rem;margin:0 auto;padding:4rem;">
data:text/html, <title>Text Editor</title><body contenteditable style="font-size:2rem;line-height:1.4;max-width:60rem;margin:0 auto;padding:4rem;">
我在Firefox和Chromium浏览器中测试过,运行完美。我估计它在其他任何支持 HTML5 的浏览器中都应该可以正常运行。