[SalesForce] onclick() event not working

My original post is here: https://stackoverflow.com/questions/26090790/input-type-file-click-doesnt-work-on-ie8-9?noredirect=1#comment40885240_26090790 .

Originally, I was using $j('#file').click() in my event handler for $j('#file-wrapper').on('click', function()'. It works for other browsers but not ie8/9. And Chase mentioned his code works by using onclick() event. I tried it. It works well in jsfiddle: http://jsfiddle.net/qy9gLtzv/ . But it doesn't work for me at all after I pasted that into my VF page. So I am guessing whether it has anything to do with the meta-data in VF?

Edit

By clicking that link in my page, I am actually getting an error at Console: object expected. The screen shot:
enter image description here

But I am not quite sure what it means. The syntax seems quite normal to me.

Best Answer

The reason for this is not due to any meta data in VF page or any onclick stuffs in Javascript - it is because IE don't like the way of clicking on hidden input file tag. So it won't work.

To walkaround this issue, you need to unhide the <input type=file> tag and use absolute positioning to put it outside the browser window. And it will work fine.

Related Topic