只要浏览器能支持HTML5,就可以在浏览器地址栏中输入一行代码:data:text/html, <html contenteditable> ,回车即可把浏览器变临时编辑器。
于是有人加强了一下,支持PHP、Python、Javascript、Java、C/C++和Ruby的语法高亮:
https://gist.github.com/4666256
PS:想做一个演示链接,可是Kindeditor不能插入这样的链接,只好放到自己的网站了。
演示地址: http://www.ipandao.com/browser-editor.html
兼容情况:
测试了一下,目前只有Chrome、Opera 12及国产双核浏览器高速模式下支持,IE系、火狐17都不行。
PHP编辑器:
Python编辑器:
Javascript:
示例代码:
<a href="data:text/html, <style type=%22text/css%22>#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id=%22e%22></div><script src=%22http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js%22 type=%22text/javascript%22 charset=%22utf-8%22></script><script>var e=ace.edit(%22e%22);e.setTheme(%22ace/theme/monokai%22);e.getSession().setMode(%22ace/mode/python%22);</script>">打开Python编辑器</a>
<a href="data:text/html, <style type=%22text/css%22>#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id=%22e%22></div><script src=%22http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js%22 type=%22text/javascript%22 charset=%22utf-8%22></script><script>var e=ace.edit(%22e%22);e.setTheme(%22ace/theme/monokai%22);e.getSession().setMode(%22ace/mode/ruby%22);</script>">打开Ruby编辑器</a>
相关文章阅读:
一行代码,浏览器变临时编辑器: http://blog.jobbole.com/32823/