[Javascript] A Timed removal of DOM elements
Paul Novitski
paul at juniperwebcraft.com
Fri Mar 28 16:15:07 CDT 2008
At 3/28/2008 11:12 AM, Peter Brunone wrote:
> Seriously, though, if you have the IDs, then you just need to
> define your rules for parsing them (I assume you meant that #q33
> would disappear after 3 seconds, rather than having #q31 disappear
> twice). Take the last character of the ID -- or just replace the
> #q3 part if your sequence goes into the double digits -- and then
> call parseInt to convert it to an integer.
Make your life easier -- either take everything after the first
character or use leading zeroes on your id numbers, e.g. q01 through q99.
> Use a function that recursively calls itself with setTimeout
One of my pet peeves is pages that run continuous javascript timeout
loops, gobbling great gobs of CPU cycles, usually for little benefit
except to strut the developer's stuff. If you do go this route,
please build in a natural termination for the process so it doesn't
just continue as long as the page is loaded, or only runs while the
page has focus. Especially in these days of tabbed browsing it's
cruel and unusual punishment to design pages that assume they are the
only thing on the visitor's desktop, particularly noticeable with
self-starting audio.
Regards,
Paul
__________________________
Paul Novitski
Juniper Webcraft Ltd.
http://juniperwebcraft.com
More information about the Javascript
mailing list