0

I create a multiply cheating system like facebook. If click on a uesrname in index.php page, this userID sent to Iframe page inside new chat box. At this moment a setInterval inside Iframe start to collect data to show.

So, I want to clear setInterval inside iframe, if I close particular chat box.

Have any way to detect if Iframe page is close to clear setInterval automatically. Or any others way to send userID to iframe page to clear setInterval.

koc
  • 955
  • 8
  • 26

1 Answers1

1

You can stop an interval using the clearInterval function.

First create an interval:

var interval = setInterval("function", 10000);

Then clear it using this:

clearInterval(interval);
Thomas
  • 537
  • 1
  • 4
  • 14
  • Have any way to detect if Iframe page is close to clear setInterval automatically. – koc Oct 05 '16 at 11:25
  • @koc what do you mean closed? do you mean detecting if the ` – Thomas Oct 05 '16 at 11:27
  • Of course, If I close a chatbox, I don`t need its iframe elements also. – koc Oct 05 '16 at 11:32
  • The answer here details how to trigger an event when an element is removed: http://stackoverflow.com/questions/2200494/jquery-trigger-event-when-an-element-is-removed-from-the-dom – Thomas Oct 05 '16 at 11:34