HTMLViewer.DocumentComplete event got fired too fast(webkit)

I’m using JavaScript to show Charts, and I copy the JS script (from Constant) into a filesystem. in App.open event.
After loading it, instantly it is deleted in DocumentComplete event like below to make it hidden.

App.Open event : Copy JavaScript
HTMLViewer.Open event: load the JavaScript
HTMLViewer.DocumentComplete event: Delete that JavaScript

It works well but sometimes, I got a problem saying there is no JavaScript to load in HTMLViewer.Open event.
It seems that HTMLViewer.DocumentComplete event got fired prior to HTMLViewer.Open event.

I think the step is correct, logically it should work.

Have you ever experienced this issue?
Otherwise, do you think there is any smarter way to accomplish this requirement?

Thanks in advance.

[quote=226317:@changwon lee]I’m using JavaScript to show Charts, and I copy the JS script (from Constant) into a filesystem. in App.open event.
After loading it, instantly it is deleted in DocumentComplete event like below to make it hidden.

App.Open event : Copy JavaScript
HTMLViewer.Open event: load the JavaScript
HTMLViewer.DocumentComplete event: Delete that JavaScript

It works well but sometimes, I got a problem saying there is no JavaScript to load in HTMLViewer.Open event.
It seems that HTMLViewer.DocumentComplete event got fired prior to HTMLViewer.Open event.

I think the step is correct, logically it should work.

Have you ever experienced this issue?
Otherwise, do you think there is any smarter way to accomplish this requirement?

Thanks in advance.[/quote]

You could set a flag in Open such as OpenHappened as Boolean then you start DocumentComplete with

If OpenHappened then //do whatever you do OpenHappened = False End if

That way even if DocumentComplete fires before Open you won’t have any collision.

It will also protect you from DocumentComplete firing several times in a row, which can be another explanation of your issue.

Smart.
Now, I’m confident I could keep the Javascript until it is loaded.

Thanks you so much!