title: File upload window opened twice in IE when called externally with jQuery
body: <p>What I have is a hidden file input and a text input. What I want is to click and focus the text input, then select a file to upload and have the file name of the selected file in the text input. The file would still be selected in the file input, so that the file can be submitted with the form.</p>
  
  <p>The script I have now works excellent in Chrome and Firefox, but not in IE (of course). What happens is when the text input has the focus and you click it, the file selection window opens twice. Actually, when you close the first one, the second one opens.</p>
  
  <p>Here is the script I have now:</p>
  
  <pre class="lang-js prettyprint-override"><code>$(function() {
  
      $('input[type=text]').focus(function() {
          $('input[type=file]').click();
      });
  
      $('input[type=text]').click(function() {
          var $this = $(this);
          if ($this.is(':focus')) {
              $this.focus();
          }
      });
  
      $('input[type=file]').change(function() {
          var $this = $(this);
          var filename = $this.val().replace(/\\/g, '/').split('/');
          $('input[type=text]').val(filename[filename.length - 1]);
      });
  
  });
  </code></pre>
  
  <p>I tried checking for IE and not calling the <code>$this.focus()</code> when clicked, but that was unsuccessful unfortunately. Instead the selection windows wasn't called at all.</p>
  
  <p>I have setup a JSFiddle here: <a href="http://jsfiddle.net/Phally/g2vkb/" rel="nofollow">http://jsfiddle.net/Phally/g2vkb/</a></p>
  
  <p>To reproduce it you have to open the Fiddle in Internet Explorer (I tried in IE10 and IE10 posing as IE9). Click on the text input and cancel. Now the text input has the focus. Then click it again. It will open the selection window. Close that by selecting a file or cancelling. Now the second window will appear.</p>
  
  <p>So the question is if someone has an idea how I can stop IE opening two file selection windows. Thanks in advance.</p>