Thanks guys :D
Printable View
Thanks guys :D
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.
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.
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>
Michael, you complete legend :)