【发布时间】:2013-10-31 01:07:51
【问题描述】:
我正在尝试制作一个greasemonkey 用户脚本,该脚本将为某个文件弹出浏览器/操作系统的“另存为对话框”。
所以想要的结果是:
var link = 'http://www.example.com/example.jpeg'; //or .zip or .doc or whatever
popout link(link); //This should make the specified link be available in the "save as dialogue"
我试过下面的代码,发现here:
var link = 'http://www.example.com/example.jpeg';
var clickEvent = document.createEvent ('MouseEvents');
clickEvent.initEvent ('click', true, true);
link.dispatchEvent(clickEvent);
但不幸的是,这并没有奏效。而且我在网上的任何地方都找不到答案,我已经搜索了几个小时:(。
如果 Greasemonkey 无需先询问就将文件保存到文件夹中也可以,但这是不可能的,因为我到处都读过。所以对话窗口仍然是一个可接受的解决方案,这样用户只需单击每个文件的“确定”。
我知道也可以推送到服务器并让服务器下载给定的文件,但我不是在寻找这样的解决方案。
编辑:还发现 an adaption of greasemonkey 确实具有 savelocally api/功能。对我来说只使用那个就足够了。但我尝试将其下载为 zip 文件,将其重命名为 .xpi 并手动将其安装为 Firefox 插件。不高兴,有人知道怎么安装吗?
【问题讨论】:
标签: javascript save greasemonkey