用窗口打开时保存文档.在chrome中打开

Saving a document when opened with window.open in chrome

本文关键字:chrome 文档 窗口 保存      更新时间:2023-09-26

我有一个用javascript打开新窗口的问题。我在一个名为"theCode"的变量中有HTML代码;

var j = window.open('')
j.document.write(theCode);
j.document.close();

下面的代码工作得很好,但在chrome中我不能保存新文档或查看源代码(选项被禁用)。在firefox中,这很好。在chrome中是否有任何解决方法?

几个月后的事实,但我很确定你可以使用数据URI:

window.open("数据:text/html; base64,"+ btoa (theCode))