我正在创建一个浏览器HTML编辑器。我使用的语法荧光笔叫做镜像,这是非常好的。
我的设置是一个iframe,其中包含正在编辑的页面的视图和用户编辑的纯文本HTML所在的textarea。
我试图将编辑的HTML从textarea插入到显示为HTML的iframe中。
这可能吗?我已经尝试过以下内容:
HTML设置:
- <iframe id="render">
- </iframe>
- <textarea id="code">
- HTML WILL BE
- HERE
- </textarea>
- <input type="submit" id="edit_button" value="Edit" />
JQuery设置:
- $('#edit_button').click(function(){
- var code = editor.getCode(); // editor.getCode() is a codemirror function which gets the HTML from the text area
- var iframe = $('#render');
- iframe.html(code)
- })
这似乎没有将HTML加载到iframe中,是否有一种特殊的方法来将HTML插入到iframe中或者是不可能的?
干杯
EEF