I create an HTML file with document.implementation.createHTMLDocument()
function.
(我使用document.implementation.createHTMLDocument()
函数创建一个HTML文件。)
Like so:(像这样:)
var doc = document.implementation.createHTMLDocument("My New Document");
And I want to download this newly create HTML document.
(我想下载这个新创建的HTML文档。)
I tried this:(我尝试了这个:)
var link = document.createElement('a');
link.href = doc;
link.download = 'newDoc.html';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
But doesn't work.
(但是不起作用。)
It redirects me to myDomain.com/[object HTMLDocument]
.(它将我重定向到myDomain.com/[object HTMLDocument]
。)
How can I download this file?(如何下载此文件?)
ask by 12318867 translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…