Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
219 views
in Technique[技术] by (71.8m points)

javascript - Tab.ID of new empty tab

I send something to active Tab in my chrome extension. But I have small problem, becouse when I opend a new empty Tab with start webpage/open seetings, or chrome://extensions. The background script extension send a error:

Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.

Anyone know how to fix this? How to get the ID of a new blank card or what to do in the "if" to avoid sending a message to the card

chrome.tabs.query({ active: true, currentWindow: true }, function(tabs) {
                        if (tabs[0].id != null) {
                            chrome.tabs.sendMessage(tabs[0].id, { msg: "msg" }, function(response) {

                            });
                        }
                    });

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...