我目前使用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