loop popup confusion

前端 未结 3 1605
悲&欢浪女
悲&欢浪女 2021-01-28 05:59

Can someone tell me how to make my URLs properly loop into the window.open I created? I’m wondering if the loop is the right answer to make each URL rotate based on

3条回答
  •  遇见更好的自我
    2021-01-28 06:54

    Just change

    urls[ rotate ],
    

    to

    urls[ (rotate++) % urls.length ],
    

    The index is incremented each iteration and % urls.length (% is used for getting the remainder after division, hence it ensures the result never grows beyond the array size). You can try it here (remember to allow popups).

提交回复
热议问题