设为首页收藏本站

LUPA开源社区

 找回密码
 注册
文章 帖子 博客
LUPA开源社区 首页 业界资讯 技术文摘 查看内容

极客无极限 一行HTML5代码引发的创意大爆炸

2013-2-2 16:57| 发布者: 红黑魂| 查看: 6257| 评论: 0|来自: CSDN

摘要: 这是最初的HTML5代码,它可以运行在最新的Chrome和Firefox中,只需在浏览器地址栏输入如下代码:1data:text/html, htmlcontenteditable但是功能十分有限,甚至没有保存功能,样式也非常简陋。于是,网友Montas修改了 ...

这是最初的HTML5代码,它可以运行在最新的Chrome和Firefox中,只需在浏览器地址栏输入如下代码:

1
data:text/html, <html contenteditable>
但是功能十分有限,甚至没有保存功能,样式也非常简陋。

于是,网友Montas修改了他的代码,使用textarea标签代替html标签,可以添加自己喜欢的样式:

1
data:text/html, <textarea style="font-size: 1.5em; width: 100%; height: 100%; border: none; outline: none" autofocus />
但bgrins依旧觉得不够好看,继续修改代码,这段代码会在你打字的时候改变“编辑器”的背景颜色,非常绚丽:
1
2
3
4
5
6
7
8
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;">

网友jecxjo希望能有存储功能:

1
data:text/html,<button onClick="SaveTextArea()">Savebutton> <script language="javascript" type="text/javascript"> function SaveTextArea() { window.location = "data:application/octet-stream," + escape(txtBody.value); } script> <textarea id="txtBody" style="font-size: 1.5em; width: 100%; height: 100%; boarder: none; outline: none" autofocus> textarea>

但上面的代码是以文件形式存储,samsonjs觉得不够方便,而且需要点击按钮,于是添加了自动保存功能:

1
data:text/html,<html lang="en"><head><style> html,body { height: 100% } #note { width: 100%; height: 100% } style> <script> var note, html, timeout; window.addEventListener('load', function() { note = document.getElementById('note'); html = document.getElementsByTagName('html')[0]; html.addEventListener('keyup', function(ev) { if (timeout) clearTimeout(timeout); timeout = setTimeout(saveNote, 100); }); restoreNote(); note.focus(); }); function saveNote() { localStorage.note = note.innerText; timeout = null; } function restoreNote() { note.innerText = localStorage.note || ''; } script> head><body><h1>Notepad (type below, notes persist)h1> <p id="note" contenteditable="">p> body>html>

现在可是云时代!仅仅这样怎能让开发者止步?minikomi使用了第三方API打造了一个 在线编辑器


酷毙
1

雷人

鲜花
1

鸡蛋

漂亮

刚表态过的朋友 (2 人)

  • 快毕业了,没工作经验,
    找份工作好难啊?
    赶紧去人才芯片公司磨练吧!!

最新评论

关于LUPA|人才芯片工程|人才招聘|LUPA认证|LUPA教育|LUPA开源社区 ( 浙B2-20090187 浙公网安备 33010602006705号   

返回顶部