I'm working on a Chrome Extension where I have to click on a <input type='file' />
in javascript, via jQuery, to get the "Save As" dialog to show up. Yes, I've been told - most browsers don't allow you to do this. However, I've discovered something very odd - I can click on an file-input element (and have the Save dialog pop-up) if I do it via the address bar, like this:
javascript: $("<input type='file' />").appendTo("body").click();
So, I figured that if I could do it there, then certainly I could do it from my content script...
Obviously I was wrong. Running $("<input type='file' />").appendTo("body").click();
from my content script not only does zilch besides appending the element, but even emulating the address bar and doing window.location = "javascript: $(\"<input type='file' />\").appendTo(\"body\").focus().click();";
does zilch as well.
My initial thought was that maybe this was some kind of chrome restriction in content scripts, but I'm wrong - the extension jsShell which works via content script, is able to run the commands and get my desired results without a hitch.
So, does anyone know why jsShell & the browser can click the file-input and get a Save dialog, but my extension can't? I've tried taking jsShell apart and figuring implementing the way it works (though I don't see anything special about the way it works), but it's STILL not working. And the console isn't revealing anything - no errors, no warnings.
This is making my head overheat, so any help is very appreciated!