admin管理员组文章数量:1320661
I have created a simple extension for use on a clients pc to add a save image option to the context menu. Googles Chrome extension documentation, plus examples quoted on the web, leads me to believe I can specify a subdirectory of the 'Downloads' folder as the download target, using 'filename' in the 'onDeterminingFilename' Event.
But I can't figure the syntax. Heres the listener with my pseudo code after 'filename':
chrome.downloads.onDeterminingFilename.addListener(function(item, suggest) {
suggest({filename: mysubdirectory + item.filename});
});
I've tried including mysubdirectory in quotes and with escaped characters, but with no change. The listener works as I've used filename: 'new name' to test it. I'm sure is very very simple, or maybe I've misunderstood the Event. Thanks.
I have created a simple extension for use on a clients pc to add a save image option to the context menu. Googles Chrome extension documentation, plus examples quoted on the web, leads me to believe I can specify a subdirectory of the 'Downloads' folder as the download target, using 'filename' in the 'onDeterminingFilename' Event.
But I can't figure the syntax. Heres the listener with my pseudo code after 'filename':
chrome.downloads.onDeterminingFilename.addListener(function(item, suggest) {
suggest({filename: mysubdirectory + item.filename});
});
I've tried including mysubdirectory in quotes and with escaped characters, but with no change. The listener works as I've used filename: 'new name' to test it. I'm sure is very very simple, or maybe I've misunderstood the Event. Thanks.
Share Improve this question asked Feb 10, 2014 at 13:31 user3292967user3292967 1411 silver badge5 bronze badges1 Answer
Reset to default 11I'd used the wrong quote marks.
This works:
chrome.downloads.onDeterminingFilename.addListener(function(item, suggest) {
suggest({filename: "mysubdirectory/" + item.filename});
});
If mysubdirectory is not present it's created. If it is present, the item is added, plus any other items downloaded. Happy days.
本文标签: javascriptChrome Extensions onDeterminingFilename syntaxStack Overflow
版权声明:本文标题:javascript - Chrome Extensions onDeterminingFilename syntax - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742065444a2418805.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论