I'm stuck because of timer issue.
Briefly, the code submits a form and the answer to the post is opened in an iFrame. An EventListener on the form allows me to detect the "submit" and apply a timer to detect if the iFrame loading is too long. But, even if the iFrame is loaded (=timer should be canceled), the timer's function is called. Here is the code :
[...]
var el = document.getElementById("myForm");
if(el){
el.addEventListener("submit", function(event){
$scope.popupOpened=false;
var iframeWindow = window.parent.document.getElementById('myIframe');
var iframeDoc = iframeWindow.contentWindow.document;
//7 seconds before the popup is shown up
$rootScope.myTimer = $timeout(function(){
window.frames[0].stop();
if(!$scope.popupOpened){
errorConnexion2();//popup opening
}
}, 7000);
iframeWindow.onload=function(){
console.log("iframe loaded");
//cancel the timer
$timeout.cancel($rootScope.myTimer);
}
});
}
[...]
I also tried with setTimeout and clearTimeout and by clearing all of them like that :Is there a way to clear all time outs?
What am I missing ? Thank you in advance !