SOAP call in Netscape

M

M B HONG 20

Hi all -

I have a .NET web service running on a remote machine, and I have
Netscape Navigator 7.0 accessing it through javascript on the client
side through SOAP javascript coding. Everything works ok when I run
it, meaning the function gets successfully called and everything is
fine. I have a window.setInterval on my client side javascript, and it
calls the web service function every x milliseconds. However, as soon
as I try to close the window, it crashes the entire Netscape program.
Can anyone help me?

thanks.
 
M

Martin Honnen

M B HONG 20 wrote:

I have a window.setInterval on my client side javascript, and it
calls the web service function every x milliseconds. However, as soon
as I try to close the window, it crashes the entire Netscape program.

Can you store the result of window.setInterval e.g.
var intervalId = window.setInterval(...)
and try to call clearInterval e.g.
<input type="button" value="close"
onclick="window.clearInterval(intervalId);
window.close();">
before the window is closed? That way it is at least possible to tell
whether a pending timer is causing the crash.

And of course your original attempts to call the web service that you
posted earlier were all synchronous calls which block the browser so you
should change that to do asynchronous calls, that might improve things.
 
M

M B HONG 20

Martin - Thanks again for your reply.

Since my application is very time sensitive, I'm afraid that I must
stick with a synchronous approach. I implemented the
window.clearInterval for the timer, and it works. However, is this the
only way to get around this crash? Because if someone clicks on the
"close" button i have created it wont crash, but if he decides to just
close it with Alt + F4 or clicking on the "x", it will crash the entire
Netscape process. I've read around and come to the conclusion that
Netscape does not have an OnClose event or something similar in its
API. any ideas? thanks.

Charles.
 
M

Martin Honnen

M B HONG 20 wrote:

I implemented the
window.clearInterval for the timer, and it works. However, is this the
only way to get around this crash? Because if someone clicks on the
"close" button i have created it wont crash, but if he decides to just
close it with Alt + F4 or clicking on the "x", it will crash the entire
Netscape process.

Try whether
window.onunload = function (evt) {
clearInterval(intervalId);
};
works and avoids the crash.
 
M

M B HONG 20

Martin -

window.onunload = function () only appears to work when the window is
reloaded/refreshed. Nothing fired when I tried to close it manually.
 
M

Martin Honnen

M B HONG 20 wrote:

window.onunload = function () only appears to work when the window is
reloaded/refreshed. Nothing fired when I tried to close it manually.

It should fire when a window is closed as the document in the window is
unloaded first.

Do you still crash when

window.onunload = function (evt) {
clearInterval(intervalId);
}

is present?
 
M

M B HONG 20

Martin -

Actually sorry, let me clarify what my application is doing first. The
reason why I must use web services is because on the server,
information is dynamically changing. What I am doing is checking to
see if the window needs to refresh. For some reason, when i call
clearInterval on the onunload event, the page does not refresh. For
testing, I put a simple alert on the onunload event like this:

function Close()
{
alert("close");
window.clearInterval(intervalId);
}

window.onunload = Close();

When i click something on the form, I guess Netscape automatically
unloads/loads the page, and the alerts come up. However, when I
manually close the window, nothing happens. But you are right, if I
have just the clearInterval on the onunload event, Netscape does not
crash. But, my application no longer works. Any advice for my
particular problem? Again, your help is greatly appreciated.

Charles.
 
V

VK

window.onunload = Close();

Try instead:

window.onbeforeunload = myFunction;

(note that there are not parenthesis after the function name in this
case)
 
M

Martin Honnen

M B HONG 20 wrote:

For
testing, I put a simple alert on the onunload event like this:

function Close()
{
alert("close");
window.clearInterval(intervalId);
}

window.onunload = Close();

It would need to be
window.onunload = Close;
to make any sense as you need to assign a function itself to the
window.onunload property and not call the function.
As for the alert it is known that alert/prompt/confirm dialogs in
onunload are swallowed if the window is closed so it does not help to
tell you whether onunload is called when the window is closed.

But you are right, if I
have just the clearInterval on the onunload event, Netscape does not
crash. But, my application no longer works.

What exactly does no longer work? Do you get any script error in the
JavaScript console?
 
M

Martin Honnen

Martin Honnen wrote:


Does it no longer work because you are trying to refresh the page but it
does not?
If I understand your current framwork correctly then you are calling the
web service to see whether to refresh the page, right?
Then it could help to try the following e.g.


var intervalId;

window.onunload = function (evt) {
if (intervalId) {
clearInterval(intervalId);
}
};

function callWebService () {
// do web service call here then depending on the result do
if (serviceReturnsRefresh) {
clearInterval(intervalId);
window.onunload = null;
window.location.reload();
}
}

intervalId = setInterval('callWebService();', 5000);

That way the onunload clearing the interval timer will prevent the crash
when the window is closed but is deactivated before your code reloads
the page.
 
M

M B HONG 20

Martin -

Upon further testing, I noticed that when the SOAP calls actually get
executed (when the page refreshes when it should) Netscape does not
crash upon close. However, when the page is functioning as it should,
it still crashes, despite the window.onunload = ... (clearInterval).
Additionally, in order for my close button to work, I had to make the
page sleep for 500 ms, or else it still crashed... Like this:

<input onclick="CloseWin();" ........>

function CloseWin()
{
window.clearInterval(intervalId);
window.setTimeout ("CloseWindow()", 500);
}

function CloseWindow()
{
window.close();
}

But, if I run the same code in FireFox 1.03, it does not crash. Maybe
this is a Netscape 7.0 specific issue? It seems as though Netscape
needs some time to clear the interval or something... And yes, your
understanding of my framework is correct. Sorry for running around in
circles... this is really driving me up the wall. Thanks for your
understanding.

Charles.
 
M

M B HONG 20

Sorry, in the first line i meant "Upon further testing, I noticed that
when the SOAP calls do not get executed (when the page does not refresh
when it should)...
 
M

Martin Honnen

M said:
But, if I run the same code in FireFox 1.03, it does not crash. Maybe
this is a Netscape 7.0 specific issue?

Firefox 1.0 is based on Mozilla 1.7 while Netscape 7.0 is based on
Mozilla 1.0 and of course lots of bugs have been fixed between 1.0 and 1.7.
I am not sure how to solve the remaining issue with the old Mozilla
1.0/Netscape 7.0 crashing, perhaps you could consider changing to
Mozilla 1.7 or Firefox 1.0.
 
M

M B HONG 20

Martin -

Thanks again for your reply. Since Netscape crashes pretty much 100%
of the time using my current implementation, I have decided to go with
the asynchronous approach and see how it performs. When using the
asynchronous method, it seems to have avoided the Netscape crash for
most of the time (it still happens sometimes, I don't know why yet),
and it still works the way I want it to. However, it seems to eat
memory while the window is open (about 60k per second is my estimate).
Do you have any idea why this occurs? I tried to put a
window.clearInterval(intervalId) upon refresh, but the memory still
goes up.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,059
Members
48,769
Latest member
Clifft

Latest Threads

Top