How to apply FileField Button click in FF?
I have this html code :
<form name="form1" id="form1" method="POST" action="">
<div dir="rtl" style="position:absolute; left: 2px; top: 0px;">
<input name="fileField2" type="file" class="accountItemFilefield" id="fileField2" />
</div>
<div style="position:absolute; z-index:2;">
<img onclick="$('#fileField2').trigger('click'); " style="cursor:pointer" src="images/browse.png" width="83" height="29" alt="" />
开发者_开发问答 </div>
</form>
This code is not working in FF and it's working successfully in IE and I don't know what is the problem.
I also tried this code :
$('#fileField2').click();
and this one :
document.getElementById('fileField2').click();
all of them are working in IE bur not in FF.
How I can solve the problem?
Thanks in advance.
This is a security restriction to prevent malicious sites from unexpectedly showing the file upload dialog.
I don't think there is a way around this. In fact, I'm surprised that IE still allows it.
document.getElementById('fileField2').click();
worked when I tried it. (I didn't try the other versions.)
The only security restriction applies if you try to launch the filepicker at a time when a popup would be blocked, in which case you get the regular blocked popup notification.
精彩评论