How can I make this function loop with javascript? -


function argstoarray(args) {   var r = []; (var = 0; < args.length; i++)     r.push(args[i]);   return r; }  argstoarray(document.getelementsbytagname('img')).foreach(function(img) {   img.src = img.src.split('vtlibolte8ycb').join('x0x810d0' + math.floor((math.random()*10)+1));; }); 

i tried adding setinterval(argstoarray,500); @ end seem have broken things.

this quite archaic , crash browser, experiment might work.

function reloadpage()   {   location.reload();   }    setinterval(reloadpage,.5); 

  1. i assume using native foreach you're targeting ie9+, instead of manually pushing collection contents array just:

    function argstoarray(args) {     return array.prototype.slice.call(args) } 
  2. the rest of code looks workable, maybe there's wrong split() or join() arguments. please explain trying achieve here.

  3. adding setinterval(argstoarray,500) call first function without arguments, should use anonymous function or pass arguments setinterval/settimeout function (see mdn).


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -