Javascript: setInterval causing browser to hang and crash (Firefox)?
I've been experimenting a bit, taught myself some Javascript within the past few days, and I found it surprisingly easy, I guess after learning my first programming language others are easier to learn than if it were my first...
Anyway, I made a clock basically... it gets the date, stores it in a variable, and replaces the paragraph with an assigned id (<p id="demo"; <script> function() { document.getElementById("demo").innerHTML=[insert code];) Stuff like that... well, in the clock, I have setInterval to execute the function to display the current time every 1000ms... I also made additional stuff like getting the individual values (hours, minutes, seconds, AM/PM) but to keep them updated I had to use setInterval to keep them updated... however, I have four setIntervals going at 1000ms and it causes the browser to hang. What's a way to have four different javascript functions going off at a set time, two at the same time, two at different assigned times?
I have three because although the timer is running at 1000ms, if I try to get seconds, it won't update with the original clock. Is it possible to get the time from one function and use the variable and value to carry on to the next function? I'll link to the calculator
https://dl.dropbox.com/u/113810822/clock.html
The program causes Google Chrome's process to increase by thousands and multiplies every second. Went from 450K to 800K in a minute