I'm curently making one chrome extension which works perfect and i would like some help in one thought.

I have set my extension to work only in my website, by the manifest file.

Now i want the users when they push a button in my website with class

```
layerConfirm

```

The extension should open a new tab with a link that i want.

```
   var element = document.getElementsByClassName('layerConfirm');
    element.onclick = function() {
        chrome.tabs.create({
            url: "http://example.com/"
        });
    };

```

If i put this code to the file "background.js" it will work? What is your opinion?

UPDATE:Or maybe i should put the following code in the popup.js file?

```
document.addEventListener('DOMContentLoaded', function() {
    var element = document.getElementsByClassName('layerConfirm');
    element.onclick = function() {
        chrome.tabs.create({
            url: "http://example.com/"
        });
    };
});

```