1

It seems simple but I have been trying this for a while. Every time I add a link to the push notification, the urls open at different tabs for different links. Actually for the first notification, it opens in a single tab, for the second notification, it opens up in two tabs with the same url accessed. The tabs keep increasing.. please help.

for(i=0;i<newItems.length; i++){
        var myItem = {
            type: "basic",
            title: "New Product Alert!",
            message: newItems[i],
            contextMessage: "Product Notifier",
            buttons: [{
                title: "View Product"

            }],
            iconUrl: "origi.png"
        };

        chrome.notifications.onButtonClicked.addListener(function(){
            window.open('https://www.product.co.ke/electronics-video/');


        });

        chrome.notifications.create(myItem);



            }
        }

The newItems array is to fetch content for a new product uploaded

1 Answers1

0

You can try out adding "_self" as a second parameter in window.open. Similar to what this issue suggested in doing.

Another route I can think of (mostly just looks like a more specific approach) is to call chrome.tabs.getCurrent inside the button click listener, and call the window.open function from there. Hopefully that will indicate Chrome that the currently viewed tab will open the url provided.

Hope this helps!

Community
  • 1
  • 1
adjuremods
  • 2,938
  • 2
  • 12
  • 17