0

Can we clear setinterval() event of one html page in another html page??

we created the setInterval('someFunction()',1000) in one html page, can we clearInterval(someFunction) in another html page?? is there any option.

11th Jan 2018, 10:18 AM
Sai Krishna
2 Answers
0
If both pages comes from same origin, you could by accessing from one document to the other, read the identifier of the interval (the returned value by setInterval()) and execute clearInterval() in the targeted document with the correct id (clearInterval/clearTimeout require an identifier as argument, not a function reference): it could be tricky, and will not work with cross-domain origin (while you doesn't have ability to change policy of targeted domain) ^^
12th Jan 2018, 7:19 AM
visph
visph - avatar
- 1
I've never tried, but it might work, if you can pass the function return to the new page. However, it might happen automatically as that function is probably gone with the page.
11th Jan 2018, 1:21 PM
John Wells
John Wells - avatar