>>>>> "Martin" == Martin Honnen <ma*******@yahoo.de> writes:
Martin> Michael Powe wrote:
I am trying to work out the usage of preventDefault() and not
having any success. The scenario is that I want to add on
onclick handler to a link. When the onclick handler fires, I
want action A to take place, which will be a request. I want
to insure that action A completes before the click to the link
retrieves the page. To do that, I would like to issue a
preventDefault(), wait for action A to complete and then direct
the browser to the page specified in the link (e.g., set
location.href="clicked_link_ref").
Martin> I don't know what "action A" is but if you have a simple
Martin> script function name actionA then you can call it in the
Martin> onclick handler e.g. <a href="whatever.html"
Martin> onclick="actionA(); return true;">link</a> and then when
Martin> the link is clicked the browser calls the onclick handler
Martin> and processes that before loading the href URL.
Martin> Or what exactly is "action A" supposed to be that you
Martin> think you need to tell the browser to wait and that
Martin> preventDefault would do that?
"Action A" sends a request for an image. This doesn't work in Firefox
and Mozilla because they don't wait for the request to complete before
proceeding with the opening of the link. The opening of the link
causes them to close the request, so it is never completed. The
mozilla dev team has told me that this is done according to the HTTP
specification and it is not a bug. IE seems to either queue the
request or wait for it; in any event, it will be completed in IE but
not in the others. It was a guy at Mozilla who suggested to me the
technique outlined above.
Additionally, it irritates me that I can't figure out how to make it
work. ;-) So I want to work it out. I'm open to suggestions of
resources to get a better understanding of the problem, too.
Thanks.
mp
--
'cat' is not recognized as an internal or external command,
operable program or batch file.