Javascript 如何更改代码,使其同时开始闪烁,并且仍然是无限的?

Javascript 如何更改代码,使其同时开始闪烁,并且仍然是无限的?,javascript,Javascript,如何更改代码,使其同时开始闪烁,并且仍然是无限的 function blink() { if (!toggleSwitch) { for (let i = 0; i < elements.length; i++) { shapes.push(elements[i].className); } // Start off at the first element. let i = 0; let len = shapes.length; // Do the

如何更改代码,使其同时开始闪烁,并且仍然是无限的

function blink() {
 if (!toggleSwitch) {

  for (let i = 0; i < elements.length; i++) {
   shapes.push(elements[i].className);

  }
  // Start off at the first element.
  let i = 0;
  let len = shapes.length;

  // Do the next link
  function doNext() {

   let element = shapes[i];
   i++;

   eval(element).fillColor = eval(element).setColor;
   document.getElementById(element).style.backgroundColor = (eval(element).fillColor === document.getElementById(element).style.backgroundColor) ? 'white' : eval(element).setColor;

   if (i < len) {
    // Don't do anything special
   } else {
    // Reset the counter
    i = 0;
   }
 ,  myVar = setTimeout(doNext, 1000);
  }

  // And the code needs kicked off somewhere
  doNext();
 }
}
函数闪烁(){
如果(!toggleSwitch){
for(设i=0;i

此外,我不能切换类,因为通过拖放,我可以在运行期间随时更改背景颜色,因此每个形状都有一个对象,其中保留了背景的颜色

要让页面先在某个暂停后调用闪烁功能,可以这样做吗

<BODY onLoad="setTimeout('blink()', 5000);">