0

In this code:

function OpenUploadFile1() {
    var myFrame = document.getElementById('frameUpload1');
    $(myFrame).focus();
    $(myFrame).contents().find("#upload_1_file").click();
    var value = $(myFrame).contents().find("#upload_1_file").val();
    if (value != '') {
        $(myFrame).contents().find("#upload_1_start").click();
    }
}

the line

var value = $(myFrame).contents().find("#upload_1_file").val();

gets executed without waiting for the user to select a file and close the dialog (after the .click above) in FF/Chrome, but works fine in IE (at least IE11).

frameUpload1 is an iframe, and upload_1_file is an asp:UploadFile control.

EDIT: for clarity, this is how the code is called:

<a href="javascript:void(0)" title="Upload Image" onclick="OpenUploadFile1()">Upload Image</a>
<iframe id="frameUpload1" name="frameUpload1" src="fileupload.aspx" frameborder="0" width="0" height="0"></iframe>

Does anyone know why and how to fix this?

Thanks in advance!

dennisV
  • 1,119
  • 3
  • 19
  • 34

1 Answers1

0

I think this two may help you :

1-instead of value != '' use value != null

2-instead of $(myFrame).contents().find("#upload_1_start") use $("#upload_1_start")

but I'm not completely sure about second.

Farhad
  • 1,873
  • 17
  • 28
  • Thanks. The problem is that if put alert('1'); right after the "var value =" line, it gets fired up while the file selection dialog is on screen. So, having "value != ''" or "value != null" probably won't help? – dennisV Mar 03 '14 at 05:57