views:

2127

answers:

2

Main Page:

<iframe src="/files/new" onload="alert('onload');"></iframe>

and inside the iframe, /files/new renders:

<form action="/files/create" method="post" enctype="multipart/form-data" >
    <input type="file" name="file1" size="28" />
    <input type="submit" value="submit" value="Submit" />
</form>

If I submit a file, iframe's onload event fires as expected. But if I submit a big file larger than the value specified in the maxRequestLength of httpRuntime in web.config, iframe's onload event doesn't fire(Only in firefox(I tested with v3.0.11). IE and Google Chrome fires onload event normally).

I'm using jQuery's ajaxSubmit to upload files and ajaxSubmit internally uses iframe and listen to onload event to notify success or failure. So If I upload a big file any callback is called in firefox and I have no way to know whether it is succeeded or failed.

+1  A: 

I often have run into problems like this so I look to skin a cat another way. Instead of using the onload, would it be possible to include something inside the frame to reference the outer part of the DOM?

For example, could you simply set a variable as part of the main parent frame window.parent.uploadComplete then use a timer to view the status of the upload complete variable?

It's not as effective as a trigger with onload, but sometimes thats the sacrifice for cross-browser compatibility.

Mech Software
+1  A: 

If you want older browsers to do something once the document has finished loading into the iframe, you can include an onload handler inside that document.

The document can then reference the containing document using the "parent" keyword.

This should solve your problem.

Ravia