我正在构建我的第一个Chrome扩展。到目前为止,我的代码需要一个网页元素并创建HTML标记(在JavaScript中以字符串加载)。用铬扩展名创建/下载.html文件
我的扩展的按钮导致
$(".column1").prepend('<div class="actions" style="margin-bottom: 1rem;"><button id="edmMaker">Make an EDM!</a></div>')
$('#edmMaker').click(function(){
var html = "<body><section><h1>Here is some HTML text</h1></section><div><p>Here's some more</p></div></body>"
// create a .html file and download it to the user's desktop
});
在Node.js的,我只想写一个.html
文件到本地磁盘,但我不能完全弄清楚如何工作的Chrome扩展的世界。
我该怎么做?
子问题:有没有什么办法来标记输出的HTML?我输出的实际代码是一个HTML电子邮件模板,而Javascript只会让我加载一个没有换行符和制表符的字符串。
\ *。咳咳\ * ['chrome.downloads'](https://developer.chrome.com/extensions/downloads)\ *咳嗽\ * – Xan 2015-02-07 15:35:43
@Xan *编辑狂怒* – mattsven 2015-02-07 15:56:28
@Xan其实,它看起来像'chrome.downloads。下载“的功能与我上面的功能非常相似。无论如何我都会收录它。我也不能告诉它它会接受一个数据URI(可能) – mattsven 2015-02-07 15:59:27