Freelancer: ElVox
Chia sẻ:
Báo cáo bài thi

jQuery Hack

Due to the security restrictions in IE 10, you need to use a label that wraps the hidden file input. This should work though there will be some slight differences in styling - probably because a button's default padding differs somewhat from the label's defaults. Anyway, the basic idea is check for IE 10 and get rid of the '#html5button*' elements and instead wrap the file input button in a label. For example: $('#html5button, #html5buttonCarFax, #html5buttonAutoCheck').remove(); // Or hide() $('#html5files').wrap('Add Image(s)'); $('#html5filesCarFax').wrap('Upload CarFax'); $('#html5filesAutoCheck').wrap('Upload AutoCheck');

Bài tham dự cuộc thi #7 cho                                                 Find the jQuery/JavaScript Bug - $50 Bounty Challenge for a Guru
Bài tham dự #7

Bảng thông báo công khai

  • kjopc
    Chủ cuộc thi
    • cách đây 10 năm

    Where do I insert your code to test it?

    • cách đây 10 năm
    1. ElVox
      ElVox
      • cách đây 10 năm

      Please, see my other clarifications. I replied separately before I saw your question here.

      • cách đây 10 năm
  • ElVox
    ElVox
    • cách đây 10 năm

    Some more to add:

    As far as integrating this code, you'll either want to 1) include just the code for one file input into each of the three inline script elements or 2) put them all at the end of the body inside a $(document).ready(..) of their own.

    I just realized that Freelancer's text input thing is mangling my code so I can't show you what I mean inline. I decided to put 1) and 2) in a private gist on github:

    https://gist.github.com/imbcmdth/37522d30f3f9af841cd0

    The first strategy mentioned above are the first 3 gists. They are just the existing inline sections with a conditional block added to the initialization code.

    The very last gist is the (much simpler) second strategy.

    • cách đây 10 năm
    1. ElVox
      ElVox
      • cách đây 10 năm

      Oh damn, I just realized that you are using jQuery v1.10 which no longer has the (quite useful) '$.browser" object... hmm.

      The only easy solution since IE10 doesn't support "conditional comments" is to use the small jQuery migrate plugin:

      https://github.com/jquery/jquery-migrate/

      I apologize for the inconvenience.

      • cách đây 10 năm