Thanks guys![]()
There is a way to do this, but it won't be as fast.
I didn't really test it, but I'm assuming that it works.Code:<script type="text/javascript"> var count = function() { if (typeof i == "undefined") i = 0; if (i < 1000000) { i++; document.getElementById("whatever").innerHTML += i; setTimeout(function() { count(i); }, 0); } } window.onload = function() { var div = document.createElement("div"); div.id = "whatever"; document.body.appendChild(div); count(); } </script>
EDIT: I did test it, it works.
Last edited by mburt; 04-03-2012 at 10:29 PM.
- Mike
But that would just print out one number wouldn't it? I'm trying to print out 100000000 numbers not the number 100000000.
No check it again, I edited it slightly, it prints out however many numbers you want. It's slower, but it won't crash your browser.
- Mike
And I actually figured out a way to make this even faster:
keyboard, you can mess with those two variables to figure out where the maximum performance lies.Code:<script type="text/javascript"> var count = function() { if (typeof i == "undefined") i = 0; var interval = 100, max = 100; if (i < max) { for (var a = i; a < i+interval; a++) { document.getElementById("whatever").innerHTML += a; } i = i+interval; setTimeout(function() { count(i); }, interval); } } window.onload = function() { var div = document.createElement("div"); div.id = "whatever"; document.body.appendChild(div); count(); } </script>
Last edited by mburt; 04-03-2012 at 10:45 PM.
- Mike
keyboard (04-04-2012)
Bookmarks