Using javascript how to break the while loop after a set time? [duplicate]
问题 This question already has answers here : Leave a loop after 2 seonds (3 answers) Closed last year . I have a while loop which looks like this: while(s1 != "#EANF#") { iimPlay("CODE:REFRESH"); iimPlay("CODE:TAG POS=1 TYPE=* ATTR=TXT:Contacted:* EXTRACT=TXT") var s1 = iimGetLastExtract(); } it will refresh the web page until it finds what it wants. However sometimes it becomes an infinite loop and I want to simply set a timer so that it would break the while loop and carry on. I tried looking