Iframe onLoad will not fire when dumping a file?
I have a simple iframe
<iframe class="ifr" src="about:blank"></iframe> To which the onload handler is attached.
$(".ifr").on('load',function (){ alert("iframe loaded") }); There are also 2 buttons:

When I click the first button (which is installed on the site (no matter which one) - it makes a warning:

However, when I set it to mypage (which uploads the image) - the image loaded , but it does not start onload .
When I click the buttons, it redirects to the page with the code:
Response.Clear(); Response.AddHeader("content-disposition", "attachment;filename=/images/about_us_bkg.jpg"); Response.AddHeader("content-length", File.ReadAllBytes(Server.MapPath("~/images/about_us_bkg.jpg")).Length.ToString()); Response.TransmitFile(Server.MapPath("~/images/about_us_bkg.jpg")); Response.End(); I believe this is due to Response.End(); .
Question:
Why (if ever) does this affect
Response.End? I mean, the browser sent a response (as an image) .... so?How can I solve this so that when the image is loaded (or iframe completes), it will fire the onload event?
ps why do i need this?
When the user clicks "upload file" on the client side, I show the animation loading and onload to remove the loading animation.
Why (if ever) it is affected by Response.End ? I mean the browser did send a response ( as a picture) , so the request is completed ....no? I don't think this is due to Response.End (if it doesn't work when you delete Response.End) you can use Context.ApplicationInstance.CompleteRequest() instead of Response.End (see Proper use of Asp.Net Response.TransmitFile and Response.End () )
How can I solve this so that when loading the image (or iframe completes) it will fire the onload event?
I think the problem is that your iframe content is not an html document or img element. Thus, it does not raise any load event.
Your aspx page may have two different behaviors that differ by query string parameter (or only two pages):
- the one that serves the image (say img.aspx, the one you already have)
- one, say document.aspx, which will be used as the
srcattribute of youriframe. document.aspx creates the whole html document containing the img element, whichsrcwill be img.aspx
Hope this helps