H
H
habrdima2016-04-29 16:27:58
JavaScript
habrdima, 2016-04-29 16:27:58

Why are alerts increasing?

There is an extension with this background

chrome.tabs.onCreated.addListener(function(tab){
    var id = tab.id;
    chrome.tabs.onUpdated.addListener(function(id, info, t){
        
        if(t.status=="complete"){
            alert(t.status)
        }
    })
    
})

each new tab shows an alert 1 times more than the previous time, why? how to fix?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2016-04-29
@habrdima

Because you are multiplying listeners - chrome.tabs.onUpdated.addListener inside chrome.tabs.onCreated.addListener creates another listener each time.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question