473,739 Members | 5,405 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

animated gif stops when doing cpu intensive task

Hi,
I have the following code that shows up a div with an animated gif
inside, executes a cpu intensive function using setTimeout and then
hide the div again:

getEl('divWaiti ng').style.disp lay = 'block';
window.setTimeo ut(function(){m e.FM.addFlagPop Box(me);
getEl('divWaiti ng').style.disp lay = 'none';}, 1000);

issue is that the animated gif will stop as soon as the function in
setTimeout starts. How can I solve this ?

Thanks

ps: me is a global variable that refers to this object.

Jul 24 '06 #1
10 2813
sa************* @googlemail.com wrote:
Hi,
I have the following code that shows up a div with an animated gif
inside, executes a cpu intensive function using setTimeout and then
hide the div again:

getEl('divWaiti ng').style.disp lay = 'block';
window.setTimeo ut(function(){m e.FM.addFlagPop Box(me);
I think you made a triple mistake here:
window.setTimeo ut(function(){m e.FM.addFlagPop Box(me);

1) it is missing the }
2) it is also missing the number of milliseconds before executing the
function.
3) The first argument should be a string to be executed, not a reference to
an anonymous function.

So try something like:
setTimeout("FM. addFlagPopBox(m e);",100);

where you are responsible to make a function with that name of course that
handles whatever it is you are trying to accomplish.

Didn't you get an errormessage on that line?
If so, you are probably using IE for development, which is a poor choiche
compared to Firefox and the likes. The latter has a javascriptconso le which
will give you detailed errormessages.

Hope that helps.
Regards,
Erwin Moller
getEl('divWaiti ng').style.disp lay = 'none';}, 1000);

issue is that the animated gif will stop as soon as the function in
setTimeout starts. How can I solve this ?

Thanks

ps: me is a global variable that refers to this object.
Jul 24 '06 #2
Hi Erwin,
Sorry I completely messed up when I pasted my code in the forum :(
My code is correct and I have no errors:

getEl('divExpan dedFlags').styl e.display = 'block';
this.CloseButto n =
getChildElement (getChildElemen t(getEl('divExp andedFlags'),
'divExpandedFla gsHeader'), 'divExpandedFla gsClose');

getEl is a function that do the same as getElementById.

Anyway, the issue is in my first post.

Sam

Erwin Moller wrote:
sa************* @googlemail.com wrote:
Hi,
I have the following code that shows up a div with an animated gif
inside, executes a cpu intensive function using setTimeout and then
hide the div again:

getEl('divWaiti ng').style.disp lay = 'block';
window.setTimeo ut(function(){m e.FM.addFlagPop Box(me);

I think you made a triple mistake here:
window.setTimeo ut(function(){m e.FM.addFlagPop Box(me);

1) it is missing the }
2) it is also missing the number of milliseconds before executing the
function.
3) The first argument should be a string to be executed, not a reference to
an anonymous function.

So try something like:
setTimeout("FM. addFlagPopBox(m e);",100);

where you are responsible to make a function with that name of course that
handles whatever it is you are trying to accomplish.

Didn't you get an errormessage on that line?
If so, you are probably using IE for development, which is a poor choiche
compared to Firefox and the likes. The latter has a javascriptconso le which
will give you detailed errormessages.

Hope that helps.
Regards,
Erwin Moller
getEl('divWaiti ng').style.disp lay = 'none';}, 1000);

issue is that the animated gif will stop as soon as the function in
setTimeout starts. How can I solve this ?

Thanks

ps: me is a global variable that refers to this object.
Jul 24 '06 #3
argggggg what am i doing, i pasted wrong code again. The code I pasted
in the first post was correct, it was split up on two lines by the
editor but it should be read as one line, look again.
samuelberthe... @googlemail.com wrote:
Hi Erwin,
Sorry I completely messed up when I pasted my code in the forum :(
My code is correct and I have no errors:

getEl('divExpan dedFlags').styl e.display = 'block';
this.CloseButto n =
getChildElement (getChildElemen t(getEl('divExp andedFlags'),
'divExpandedFla gsHeader'), 'divExpandedFla gsClose');

getEl is a function that do the same as getElementById.

Anyway, the issue is in my first post.

Sam

Erwin Moller wrote:
sa************* @googlemail.com wrote:
Hi,
I have the following code that shows up a div with an animated gif
inside, executes a cpu intensive function using setTimeout and then
hide the div again:
>
getEl('divWaiti ng').style.disp lay = 'block';
window.setTimeo ut(function(){m e.FM.addFlagPop Box(me);
I think you made a triple mistake here:
window.setTimeo ut(function(){m e.FM.addFlagPop Box(me);

1) it is missing the }
2) it is also missing the number of milliseconds before executing the
function.
3) The first argument should be a string to be executed, not a reference to
an anonymous function.

So try something like:
setTimeout("FM. addFlagPopBox(m e);",100);

where you are responsible to make a function with that name of course that
handles whatever it is you are trying to accomplish.

Didn't you get an errormessage on that line?
If so, you are probably using IE for development, which is a poor choiche
compared to Firefox and the likes. The latter has a javascriptconso le which
will give you detailed errormessages.

Hope that helps.
Regards,
Erwin Moller
getEl('divWaiti ng').style.disp lay = 'none';}, 1000);
>
issue is that the animated gif will stop as soon as the function in
setTimeout starts. How can I solve this ?
>
Thanks
>
ps: me is a global variable that refers to this object.
Jul 24 '06 #4
sa************* @googlemail.com wrote:
argggggg what am i doing, i pasted wrong code again. The code I pasted
in the first post was correct, it was split up on two lines by the
editor but it should be read as one line, look again.
Hi,

Nevermind, if you live in Europe you are probably desintegrating because of
the heat just like me. ;-)

Still, here is your original code:

getEl('divWaiti ng').style.disp lay = 'block';
window.setTimeo ut(function(){m e.FM.addFlagPop Box(me);
getEl('divWaiti ng').style.disp lay = 'none';}, 1000);

This indeed solves my comment 1 and 2, but 3 still stands:
"The first argument should be a string to be executed, not a reference to an
anonymous function."

You are still not passing a string to setTimeout.
You should call it like this: setTimeout("STR ING HERE", 1000);

And again: Why didn't you see an error?

So this has little to do with high CPU load, but with an invalid call to
setTimeout().

I am unsure if you can pass an Objectreference s to a setTimeout function.
I always avoid such situations anyway by simply calling a function with a
string-parameter, or an integer, that handles the whole shebang.
Like this:
setTimeout("doF lagPopBoxStuff( 'me');", 1000);

and in doFlagPopBoxStu ff you make sure you make a valid reference to your
me-object. Then do your stuff with it.

The reason I warn you about this is simply that when the 1000 millies pass,
your reference can be invalid (eg a removed form-element).

Hope that helps,

Regards,
Erwin Moller
>

samuelberthe... @googlemail.com wrote:
>Hi Erwin,
Sorry I completely messed up when I pasted my code in the forum :(
My code is correct and I have no errors:

getEl('divExpa ndedFlags').sty le.display = 'block';
this.CloseButt on =
getChildElemen t(getChildEleme nt(getEl('divEx pandedFlags'),
'divExpandedFl agsHeader'), 'divExpandedFla gsClose');

getEl is a function that do the same as getElementById.

Anyway, the issue is in my first post.

Sam

Erwin Moller wrote:
sa************* @googlemail.com wrote:

Hi,
I have the following code that shows up a div with an animated gif
inside, executes a cpu intensive function using setTimeout and then
hide the div again:

getEl('divWaiti ng').style.disp lay = 'block';
window.setTimeo ut(function(){m e.FM.addFlagPop Box(me);

I think you made a triple mistake here:
window.setTimeo ut(function(){m e.FM.addFlagPop Box(me);

1) it is missing the }
2) it is also missing the number of milliseconds before executing the
function.
3) The first argument should be a string to be executed, not a
reference to an anonymous function.

So try something like:
setTimeout("FM. addFlagPopBox(m e);",100);

where you are responsible to make a function with that name of course
that handles whatever it is you are trying to accomplish.

Didn't you get an errormessage on that line?
If so, you are probably using IE for development, which is a poor
choiche compared to Firefox and the likes. The latter has a
javascriptconso le which will give you detailed errormessages.

Hope that helps.
Regards,
Erwin Moller

getEl('divWaiti ng').style.disp lay = 'none';}, 1000);

issue is that the animated gif will stop as soon as the function in
setTimeout starts. How can I solve this ?

Thanks

ps: me is a global variable that refers to this object.
Jul 24 '06 #5
Erwin Moller wrote:
<snip>
This indeed solves my comment 1 and 2, but 3 still stands:
"The first argument should be a string to be executed, not a reference
to an anonymous function."
This is not true, at least from IE 4, Netscape 4, opera 6 and many
others. A function reference may be the first argument to setTimeout,
Indeed it can be argued that a function reference is a better argument
to use, partly because it can be executed faster (not needing
interpreting into code) and partly because a string object can be
provide with a custom toString method that would return a string that
effectively called the function, providing optimum performance plus
full backward compatibility with older setTimeout implementations that
only accept string arguments.
You are still not passing a string to setTimeout.
You should call it like this: setTimeout("STR ING HERE", 1000);

And again: Why didn't you see an error?
<snip>

Even on an implementation that only accepts string arguments the effect
of passing a function reference would be expected to be implicit
type-conversion of the function to a string, and as toString methods of
functions objects traditionally return the function's source code (more
or less) the string executed by the timeout would be a string of
javascript code that defined a function. No error would be expected
when this was executed, although no actual effects would be expected
either.

Richard.

Jul 24 '06 #6
Nevermind, if you live in Europe you are probably desintegrating because of
the heat just like me. ;-)
It's bloody hot indeed .. :)

As Richard said, it works for me... No error at all, whether with IE or
FF. That bit of code works just fine. Actually as I keep saying there
is nothing wrong with my code. However, it should be modified to
accommodate new requirement, which is allowing the gif to animate even
when the cpu intensive task is being executed. And THAT is my problem
:)
Anyone knows how I could do that ?

cheers,
Sam

Jul 24 '06 #7
Richard Cornford wrote:
Erwin Moller wrote:
<snip>
>This indeed solves my comment 1 and 2, but 3 still stands:
"The first argument should be a string to be executed, not a reference
to an anonymous function."

This is not true, at least from IE 4, Netscape 4, opera 6 and many
others. A function reference may be the first argument to setTimeout,
Indeed it can be argued that a function reference is a better argument
to use, partly because it can be executed faster (not needing
interpreting into code) and partly because a string object can be
provide with a custom toString method that would return a string that
effectively called the function, providing optimum performance plus
full backward compatibility with older setTimeout implementations that
only accept string arguments.
Hi Richard,

Maybe that is true, maybe not.
My wisdom comes from O'Reilly's "Javascript , the definitive Guide, 4th
edition, covers Javascript 1.5".
It states clearly it want a string (page 679), no notes about a
functionreferen ce whatsoever.

So I won't ague that you are wrong, I just want to note that is not
described in 'the guide'.

>
>You are still not passing a string to setTimeout.
You should call it like this: setTimeout("STR ING HERE", 1000);

And again: Why didn't you see an error?
<snip>

Even on an implementation that only accepts string arguments the effect
of passing a function reference would be expected to be implicit
type-conversion of the function to a string, and as toString methods of
functions objects traditionally return the function's source code (more
or less) the string executed by the timeout would be a string of
javascript code that defined a function. No error would be expected
when this was executed, although no actual effects would be expected
either.
Aha, that clears that mystery up then!

Is this the same reason you can pass a function-reference to setTimeout?
Becuase it is converted via toString() to (a copy of?) the original
function?

Thanks for the explanation.

Regards,
Erwin Moller

>
Richard.
Jul 24 '06 #8
Erwin Moller wrote:
Richard Cornford wrote:
>Erwin Moller wrote:
<snip>
>>"The first argument should be a string to be executed, not a reference
to an anonymous function."

This is not true, ...
<snip>
Maybe that is true, maybe not.
My wisdom comes from O'Reilly's "Javascript , the definitive Guide, 4th
edition, covers Javascript 1.5".
It states clearly it want a string (page 679), no notes about a
functionreferen ce whatsoever.

So I won't ague that you are wrong, I just want to note that
is not described in 'the guide'.
The "definitive guide" is only the least bad javascript book available,
that doesn't meant it is good, comprehensive, accurate, wise or
definitive.

<snip>
>Even on an implementation that only accepts string arguments the effect
of passing a function reference would be expected to be implicit
type-conversion of the function to a string, and as toString methods of
functions objects traditionally return the function's source code (more
or less) the string executed by the timeout would be a string of
javascript code that defined a function. No error would be expected
when this was executed, although no actual effects would be expected
either.

Aha, that clears that mystery up then!

Is this the same reason you can pass a function-reference to setTimeout?
Becuase it is converted via toString() to (a copy of?) the original
function?
<snip>

No, the source code for a function declaration or a function expression
will be just a function declaration or a function expression; you need
call operators in addition to actually execute them.

Richard.

Jul 24 '06 #9
Erwin Moller <si************ *************** *************** @spamyourself.c omwrites:

[function parameter to setTimeout/setInterval]
My wisdom comes from O'Reilly's "Javascript , the definitive Guide, 4th
edition, covers Javascript 1.5".
It states clearly it want a string (page 679), no notes about a
functionreferen ce whatsoever.
It's just a reference book, not the definition.
For authoritative definitions by the people actually implementing setTimeout,
see:
<URL:http://developer.mozil la.org/en/docs/DOM:window.setT imeout>
<URL:http://msdn.microsoft. com/workshop/author/dhtml/reference/methods/settimeout.asp>

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 24 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3602
by: Kwok Ng | last post by:
Hi folks, In IE, the animated gif will stop after the form is submitted. I even put the animated gif in the iframe, still no luck. Would anybody know any workaround? Thanks! Billy Ng
1
1011
by: metsymani | last post by:
In my web application, I have a search screen coded in ASP.Net. The Search process takes lot of time. So, I need to show a wait page informing the user that "Search is in progress. Please wait" along with an animated gif. I have placed a div in the search page which contains the message and animated gif. I hide the div by making "display: none" in the onload function of the body tag. On click of the Search button(type = Submit), I call a...
3
3440
by: Al | last post by:
Hi all... I have created an aspx page that contains an animated GIF. I am using javascript and location.replace to redirect from this page to another aspx page which takes several seconds to load. When location.replace is called the animated GIFs in the first page stop animating. Is this standard behaviour? If so, is there an easy work around to prevent this?
3
25487
by: bdog4 | last post by:
I've seen on some php forums that they use some type of popup box that I assume is javascript to display a animated gif/flash when you do a quick edit. My popup blocker does not detect it so I leads me to believe it is javascript. Does anyone have an ideas on how I can do this or an example/tutorial? They use it on Invision Power Boards Thanks
4
1582
by: Fao, Sean | last post by:
I'm trying to show an animated image temporarily while the web server is processing a long request. I attempted to use a combination of CSS styles and JavaScript to temporarily hide or show only appropriate portions of the page (e.g. hide the data and show an animated "processing" image while the server is doing work), however, it's not exactly working out the way I had hoped. What's the best way to accomplish this task? Thank you in...
2
3800
by: Mark D. Smith | last post by:
Hi i have to popup (argh) a small page when an animated gif is clicked on. the animation stops as soon as the popup opens. is there a way to restart the gif or prevent it from stopping in the first place? the popup uses the javascript below function popUpLaunch(url) { newWindow=window.open(url, 'windowNew',
2
2654
by: Dale Reed | last post by:
Hi, I have a button on an aspx page (I'm using vs2005 with asp2), which when clicked takes a while to do some data processing before it posts back to the screen to display the results. I therefore created a little animated gif, which, when the button is clicked, I display using javascript in a floating div, the idea being that the animation shows that something is happening until the postback occurs.
4
8049
by: Chris Moltisanti | last post by:
Hi, I am executing a piece of javascript that does some intensive processing (sorting large tables). This can take a good few seconds so I have an animated gif as a progress bar to let the user know that something is happening. However, the GIF does not animate when the javascript is processing. Anyone know why? I am aware that animated GIFs stop animating when a page is loading, but I am not loading the page here.
4
6362
by: Jeff | last post by:
Hi, I'd like to write Javascript that stops animated gifs from animating. On Firefox, at least, window.stop(); does the trick, although it stops everything on the page and is kind of unpredictable. If I connect it to the onload event, sometimes only half the page will be displayed. Does the onload even fire before rendering? Does anyone know a reasonable way to accomplish my original goal of
0
8969
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8792
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9266
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9209
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8215
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6754
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4570
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4826
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3280
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.