Javascript Timing Issues

The following timing issues have been observed when writing Elink Javascript

1. Invoking active X scripts during page loading can cause strange lock-up; the page fails to display correctly. Refer to the Executing SQL in Javascript page for an example.
2. Opening an edit page and immediately refreshing the existing page has timing issues.

As an example of the second of these, consider the following code:

EditAction(-1,idaction);
top.location.reload();

The problem with this code is that EditAction() does not open the action editing window, it only initiates the opening on this window. So it is entirely possible that the reload will occur before the action editing window has been fully opened. The consequence of this is that the action editing window does not work as expected. In particular, I have observed strange apply button behaviour, where the apply button reloads the parent window into the the action editing window.

The workaround for this problem is to delay the reload until the edit window has fully opened:

EditAction(-1,idaction);
window.setTimeout(“top.location.reload();”, 5000);

This code gives the EditAction five seconds to open the edit window before causing the parent window to reload.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>