Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Showing a 'Waiting ...' Message

Reply
Thread Tools

Showing a 'Waiting ...' Message

 
 
Mel Smith
Guest
Posts: n/a
 
      12-13-2011
Hi:

Because of some great help from Denis McMahon last March, I've been
showing / sorting big tables with no problem

The only problem I have is displaying a 'Waiting for Sort to Complete
....' message on the screen during the interval that sorting is taking place.

The 'Wait' Message *does* display if I follow it with an Alert()
message. Otherwise, it does *not* display.

Is there some other way to *force* this following function to display ??

// **** here is the 'wait' message function ****
function showwaitmsg() {
var el = document.getElementById("sorttext")
el.style.color="white";
el.style.background="red" ;
el.value = " Sorting ... " ; // in IE7 and also Chrome, this doesn't
display UNLESS you show an alert() message first
return ;
}
// **** end of wait message function ****

Thanks for any hints provided !

--
Mel Smith


 
Reply With Quote
 
 
 
 
Gene Wirchenko
Guest
Posts: n/a
 
      12-13-2011
On Tue, 13 Dec 2011 10:26:34 -0700, "Mel Smith"
<(E-Mail Removed)> wrote:

> Because of some great help from Denis McMahon last March, I've been
>showing / sorting big tables with no problem
>
> The only problem I have is displaying a 'Waiting for Sort to Complete
>...' message on the screen during the interval that sorting is taking place.
>
> The 'Wait' Message *does* display if I follow it with an Alert()
>message. Otherwise, it does *not* display.
>
> Is there some other way to *force* this following function to display ??


You are not the only one to do battle with this. I am another. I
found in my searching that many people had this problem. I do not
have a for-sure answer, but for what it is worth...

In my case, it was a tictactoe program. I was not always getting
the display updated with the final plays before the win/lose alert()
was displayed.

>// **** here is the 'wait' message function ****
>function showwaitmsg() {
> var el = document.getElementById("sorttext")
> el.style.color="white";
> el.style.background="red" ;
> el.value = " Sorting ... " ; // in IE7 and also Chrome, this doesn't
>display UNLESS you show an alert() message first
> return ;
>}
>// **** end of wait message function ****
>
> Thanks for any hints provided !


In my case, I replaced the alert() with a setTimeout() to call
another function (consisting of the alert() I wanted) with a timeout
of 0 and then ended execution. It is important that execution end, or
the function specified in the setTimeout() will not execute.

I found that 0 worked just fine. I suspect that this allows the
screen update thread an opportunity to run.

In a related vein, I was trying to write something that would
show an update such as
1000 thingies somethingerised
2000 thingies somethingerised
3000 thingies somethingerised
I got something that worked reliably, but unfortunately, I threw out
my code. IIRC, my loop variable had to be global. I have tried to
recreate the code, but the following does not quite work. The
document.write() causes Looping() to become undefined! If I use an
alert() instead (which rather defeats the purpose), it works.

***** Start of Semi-Working Code *****
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<title>trytimeout.html</title>

<script type="text/javascript">

var i;

function LoopStart()
{
alert("{LoopStart()");
i=1;
setTimeout("Looping()",0);
}

function Looping()
{
alert("{Looping @i="+i);
DoSomething();
if (i%3==0)
document.writeln(i+" thingies somethingerised<br>"); //*****
This causes trouble.
i++;
if (i<=10)
{
alert("@Looping() <setTimeout() @i="+i);
setTimeout("Looping()",0);
alert("@Looping() >setTimeout() @i="+i);
}
}

function DoSomething()
{
for (var i=1; i<=1000; i++)
;
}

</script>

</head>

<body>

<script type="text/javascript">
LoopStart();
</script>

</body>

</html>
***** End of Semi-Working Code *****


The above is a semi-educated guess, and I would welcome
correction if there is a reliable, cross-platform way to do it.

Sincerely,

Gene Wirchenko
2
 
Reply With Quote
 
 
 
 
Mel Smith
Guest
Posts: n/a
 
      12-13-2011
Gene:

Thanks for the code. I'll work on trying to implement it and let you
know.

-Mel Smith


 
Reply With Quote
 
Gene Wirchenko
Guest
Posts: n/a
 
      12-14-2011
On Tue, 13 Dec 2011 15:31:41 -0700, "Mel Smith"
<(E-Mail Removed)> wrote:

> Thanks for the code. I'll work on trying to implement it and let you
>know.


I am going to take another whack at it. I had it working.
HONEST! REALLY! I thought I had the issue dealt with and so could
toss the code.

Sincerely,

Gene Wirchenko
 
Reply With Quote
 
Gene Wirchenko
Guest
Posts: n/a
 
      12-14-2011
On Tue, 13 Dec 2011 17:50:10 -0800, Gene Wirchenko <(E-Mail Removed)>
wrote:

>On Tue, 13 Dec 2011 15:31:41 -0700, "Mel Smith"
><(E-Mail Removed)> wrote:
>
>> Thanks for the code. I'll work on trying to implement it and let you
>>know.

>
> I am going to take another whack at it. I had it working.
>HONEST! REALLY! I thought I had the issue dealt with and so could
>toss the code.


I think I originally had it working with console.log(). I got
the to work when I changed the document.writeln() to console.log().

Does anyone know why the document.writeln() causes Looping() to
become undefined?

Sincerely,

Gene Wirchenko
 
Reply With Quote
 
Martin Pearman
Guest
Posts: n/a
 
      12-14-2011
On Dec 14, 2:10*am, Gene Wirchenko <(E-Mail Removed)> wrote:
> On Tue, 13 Dec 2011 17:50:10 -0800, Gene Wirchenko <(E-Mail Removed)>
> wrote:
>
> >On Tue, 13 Dec 2011 15:31:41 -0700, "Mel Smith"
> ><(E-Mail Removed)> wrote:

>
> >> * *Thanks for the code. *I'll work on trying to implement it andlet you
> >>know.

>
> > * * I am going to take another whack at it. *I had it working.
> >HONEST! *REALLY! *I thought I had the issue dealt with and so could
> >toss the code.

>
> * * *I think I originally had it working with console.log(). *I got
> the to work when I changed the document.writeln() to console.log().
>
> * * *Does anyone know why the document.writeln() causes Looping() to
> become undefined?
>
> Sincerely,
>
> Gene Wirchenko


http://www.google.co.uk/search?q=jav...ient=firefox-a

Typically any use of document.write() after the page has loaded will
replace the entire page content.

So your javascript is wiped out and Looping() is undefined.

Martin.
 
Reply With Quote
 
Gene Wirchenko
Guest
Posts: n/a
 
      12-14-2011
On Tue, 13 Dec 2011 23:07:21 -0800 (PST), Martin Pearman
<(E-Mail Removed)> wrote:

>On Dec 14, 2:10*am, Gene Wirchenko <(E-Mail Removed)> wrote:
>> On Tue, 13 Dec 2011 17:50:10 -0800, Gene Wirchenko <(E-Mail Removed)>
>> wrote:
>>
>> >On Tue, 13 Dec 2011 15:31:41 -0700, "Mel Smith"
>> ><(E-Mail Removed)> wrote:

>>
>> >> * *Thanks for the code. *I'll work on trying to implement it and let you
>> >>know.

>>
>> > * * I am going to take another whack at it. *I had it working.
>> >HONEST! *REALLY! *I thought I had the issue dealt with and so could
>> >toss the code.

>>
>> * * *I think I originally had it working with console.log(). *I got
>> the to work when I changed the document.writeln() to console.log().
>>
>> * * *Does anyone know why the document.writeln() causes Looping() to
>> become undefined?


>http://www.google.co.uk/search?q=jav...ient=firefox-a
>
>Typically any use of document.write() after the page has loaded will
>replace the entire page content.
>
>So your javascript is wiped out and Looping() is undefined.


I have a number of pages that do have document.write() calls in
them, and they work fine. The pages are presumably loaded at the time
the document.write() calls are made as some of those are in the body.
In one page, the body consists only of JavaScript code: a variable
creation and four document.write() calls using the variable and a
method defined in the head.

Could you please clarify your response?

Sincerely,

Gene Wirchenko
 
Reply With Quote
 
Dr J R Stockton
Guest
Posts: n/a
 
      12-14-2011
In comp.lang.javascript message <(E-Mail Removed)>, Tue,
13 Dec 2011 10:26:34, Mel Smith <(E-Mail Removed)> posted:

>
> The only problem I have is displaying a 'Waiting for Sort to Complete
>...' message on the screen during the interval that sorting is taking place.


Display the message as the last thing but one that gets executed. The
last thing is a setTimeout that calls the sort routine after some short
interval, say 100 ms. At the end of the sort, remove or alter the wait
message.

--
(c) John Stockton, nr London, UK. ???@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.

Food expiry ambiguities: <URL:http://www.merlyn.demon.co.uk/date2k-3.htm#Food>
 
Reply With Quote
 
Gene Wirchenko
Guest
Posts: n/a
 
      12-14-2011
On Wed, 14 Dec 2011 21:18:21 +0100, Jake Jarvis
<(E-Mail Removed)> wrote:

>On 14.12.2011 19:46, Gene Wirchenko wrote:
><snip>
>>
>> I have a number of pages that do have document.write() calls in
>> them, and they work fine. The pages are presumably loaded at the time
>> the document.write() calls are made as some of those are in the body.
>> In one page, the body consists only of JavaScript code: a variable
>> creation and four document.write() calls using the variable and a
>> method defined in the head.
>>
>> Could you please clarify your response?
>>

>
>In effect you are "overwriting" the old document with a new one, what
>happens with the "script environment" associated with the old document
>is anyone's guess, chrome for example guesses it should be kept around,
>firefox doesn't.
>
>But document.write doesn't always mean "overwrite", it can also mean
>"insert" into what the browser is currently reading and from which it'll
>build a document.


So how do I tell that the page has been loaded or that it is not
yet? That page with a JavaScript-only body ends scant bytes after,
and its document.write() calls do not clear the page.

Sincerely,

Gene Wirchenko
 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      12-14-2011
Gene Wirchenko wrote on 14 dec 2011 in comp.lang.javascript:

> So how do I tell that the page has been loaded or that it is not
> yet? That page with a JavaScript-only body ends scant bytes after,
> and its document.write() calls do not clear the page.


A page is loaded when all html and direct script is executed and before
body.onload starts executing.

All code that starts after that point and contains ..

document.write()

... executes an implicit ''

document.open()

... first,
thereby destroying the loaded document and starting a new document.

Such code starts by an event-listener, like:
onload='myfunction()';
onfocus='myfunction()';
onclick='myfunction()';
setTimeout('myfunction()',milisecs);
etc.

In short, you cannot document.write() into[!!] a page/document
that is ready [="loaded"].

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sh Crypto isakmp sa is showing Active but Tunnel is showing line protocol down. urvin Cisco 0 04-15-2008 08:17 AM
ChangePassword control not showing failure message PJ6 ASP .Net 1 04-13-2008 10:04 AM
QueueBrowser not scaning all messages in JMS queue (ie not showing inprogress message thilsen Software 0 07-10-2007 12:27 PM
ASP 1.1: DataGrid - Showing/Not Showing Buttons Ray Booysen ASP .Net 2 03-28-2006 02:49 PM
Message showing graeme@invalid Firefox 2 01-21-2005 03:03 AM



Advertisments