Note that there are some explanatory texts on larger screens.

plurals
  1. PODealing with a very weird gChrome/Javascript problem
    primarykey
    data
    text
    <p>I'm working on a Chrome Extension where I have to click on a <code>&lt;input type='file' /&gt;</code> 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:</p> <pre><code>javascript: $("&lt;input type='file' /&gt;").appendTo("body").click(); </code></pre> <p>So, I figured that if I could do it there, then certainly I could do it from my content script...</p> <p>Obviously I was wrong. Running <code>$("&lt;input type='file' /&gt;").appendTo("body").click();</code> from my content script not only does zilch besides appending the element, but even emulating the address bar and doing <code>window.location = "javascript: $(\"&lt;input type='file' /&gt;\").appendTo(\"body\").focus().click();";</code> does zilch <em>as well.</em></p> <p>My initial thought was that maybe this was some kind of chrome restriction in content scripts, but I'm wrong - the extension <a href="https://chrome.google.com/webstore/detail/kmgmkbicahmbceidoidjbkbpkfogaldh" rel="nofollow">jsShell</a> which works via content script, is able to run the commands and get my desired results without a hitch.</p> <p>So, does anyone know why jsShell &amp; 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.</p> <p>This is making my head overheat, so any help is very appreciated!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload