How to: Fix OCUpload/One-Click Upload clicking bug in IE7 & IE8 (jquery)

Problem: Help! I’m using the OCUpload, or One Click Upload Plugin for Jquery. IE7 and IE8 is requiring me to do a double click to display the upload dialog box!

Solution: The one-click upload technique uses a trick that sets the file input’s browse button directly in front of your mouse cursor. This is misbehaving in IE7/IE8 due to how they handle CSS, this can be resolved by directly setting the cursor position through javascript instead. You can fix the problem by editting the script and updating the following lines (highlighted in bold):

Somewhere on line 87:

/** Move the input with the mouse to make sure it get clicked! */
container.mousemove(function(e){
   input.css({
       top: e.pageY-container.offset().top+’px’,
       left: e.pageX-container.offset().left-175+’px’
   });
});

Finally, we need to set the margin css property to 0, you can find it somewhere on line 63:

/** File Input */
var input = $(
       ‘<input ‘+
       ‘name=”‘+options.name+’” ‘+
       ‘type=”file” ‘+
       ‘hidefocus=”true” ‘+
     ‘/>’
).css({
     background: ‘#ffffff’,
     position: ‘relative’,
     display: ‘block’,
     marginLeft: 0+’px’,
     opacity: 0
});

120x20 thumb black How to: Fix OCUpload/One Click Upload clicking bug in IE7 & IE8 (jquery)

That’s it! Hope this helped!

Some links that you might find useful [External]:

Related posts:

  1. Jquery Super Tip! Automatically highlight the links/menu of the current page with 1 line of code

Still can't see what you're looking for?



One Response to “”

  1. Internet Explorer 8 is very good because it is as stable as Opera. I hate the previous versions of IE like IE6 because it hangs frequently. |

  2. Victoria Young on April 29th, 2010 at 2:04 AM

Leave a Reply

Anti-Spam Protection by WP-SpamFree