Jump to content

Onabort Equivalent For Window Object?


djp1988
 Share

Recommended Posts

I am searching a way that i can detect if a user cancels the page loading in another page into an iFrame, I thought of onabort but this is only for images, is there something similar for the window object?

Link to comment
Share on other sites

You can user a server-side script, for example when calling the page generate a record in the DB for that call with 0 value, then when it is loaded send by AJAX a call to modify that record in the DB to 1. That way you will know which pages did not load because they have 0 value in the DB. I hope this helps.

Link to comment
Share on other sites

Ok that won't work the problem is I've got a form to upload a photo, and so I'm sending the POST data to another page via an iFrame as opposed to via AJAX. Next problem, is that once the person hits the send button, I hide the entire form with css and display a rotating loading style gif instead, with css. When the photo has been processed in the iframe, my php script generates some javascript to call a parent function, which inverses the css i did to hide the form, therefore you can upload another photo.The first major problem i found was sometimes internet explorer, for whatever reason, would simply display a "can't display the page", for the page I was relying on to call the parent's javascript function, so my loading gif would stay there, and that would be the end of that.To get round this, I used a readystatechange and looked for it's readyState == 'complete' (in IE, or simple == 4 in other browsers), so now I know when the iframe is loaded, and by playing on a boolean variable I would tell if the parent javascript function was called and so displaying the form.So at this point I was very happy with my script, until I tried a different approach, i send the photo to be uploaded, and before the process had finished I'd click the "X" button in the browser interface, and stop loading the page, How can I detect a 'halt' in the iframe's loading? Or easier is there no onabort for iframe object?I think the later is quite logical but it doesn't exist

Link to comment
Share on other sites

Anyone?I found some other person with the same problem, maybe he described it in a more simple way, here's how he put it:==I experimented with a snippet of JavaScript that will display a "PleaseWait" message and graphic while the results of a cgi script is running (thescript grabs a bunch of data and formats it in a table). Once the page hasloaded, the script clears the message and graphic. It works fine, howeverif you click the button on the browser to cancel the page load, the browserwill render what it can of the table and the "Please Wait" message andgraphic is still displayed.Is there an event that can be acted upon when the user clicks the browser'scancel button that would allow me to turn the display of the message off?==I found the onstop event, but this is only IE, also I couldn't find a way to use it with the iframe, but anyway, IE seems to not be a problem, when you click the stop button in the browser interface, the webpage you're onstops loading, but it would seem the iframe carries on... I know this because the loading bar still progresses. IE was easy to get around in any case because i could track the onreadystatechange event of the iframe document. But for all other browsers I can only use onload, I thought of using !onload, but that's not what i want either, if only an event called loading existed ! I could then just check if the iframe was !loading

Link to comment
Share on other sites

Your only option is to find a reference of events attached to the window or frame object and look for one that works. If the browsers don't support something like that, then that's that. There's a reference for the window object here:https://developer.mozilla.org/en/DOM/window

if only an event called loading existed ! I could then just check if the iframe was !loading
That would be a property, not an event. You can't negate an event, that doesn't have a meaning. Edited by justsomeguy
Link to comment
Share on other sites

sorry, got my terms mixed upOn that link you gave me, there's listed:window.onabortStrange this is the only place I see it listed as an event or the window object, in all my books and in previous research online I could only get this event for an img element

Edited by djp
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...