0

I was trying to load pages changing the last value of the url. It seems to work only with the last number (j=19). I don't undestand why it seems to skip the other pages.

<!DOCTYPE html>
<html>
<head>
<script>
function newIP(n) {
    window.location.replace("@@@@@:"+n)

}
</script>
</head>
<body>

<script>
var j;
for (j=0; j<20; j++) {
    window.setInterval(newIP(j), 1000);
}
</script>
</body>
</html>
v.stef
  • 1
  • See [How can I pass a parameter to a setTimeout() callback?](http://stackoverflow.com/questions/1190642/how-can-i-pass-a-parameter-to-a-settimeout-callback), but then you'll just load the first value instead of the last. Once you've redirected to another page the script execution stops. – JJJ Dec 07 '16 at 18:27
  • Note that this isn't a closure issue (yet) so not a duplicate of that question. – JJJ Dec 07 '16 at 18:30

0 Answers0