我目前使用document.write来将html注入到我的框架中。我使用Backbone,Marionette,require.js,jQuery。避免document.write?任何替代品?
我想避免使用document.write,因为它有性能和浏览器的影响。
请提出替代方案。
我当前的代码:
var html = this.compilePageHtml(); //We get some HTML code
this._previewWindow = window.open("about:blank", "PreviewWindow","width=320, height=570, scrollbars=yes");
this._previewWindow.document.write(html); //Loads HTML in new window popup
为什么不使用'的.html()',而不是..的 – qtgye 2015-02-06 05:40:58
可能重复(http://stackoverflow.com/questions/4537963/what-are-alternatives-to-document-write) – 2015-02-06 05:46:54
在jQuery中:$(this._previewWindow.document).html(html); – MaxZoom 2015-02-06 05:52:48