devtools.inspectedWindow.tabId
devtools のこのインスタンスがアタッチされる tab
の ID。番号で表されます。
これは拡張機能のバックグラウンドページに送信できるため、バックグラウンドページは tabs
API を使用してタブと対話できます:
js
// devtools-panel.js
const scriptToAttach = "document.body.innerHTML = 'Hi from the devtools';";
attachContentScriptButton.addEventListener("click", () => {
browser.runtime.sendMessage({
tabId: browser.devtools.inspectedWindow.tabId,
script: scriptToAttach,
});
});
js
// background.js
function handleMessage(request, sender, sendResponse) {
browser.tabs.executeScript(request.tabId, {
code: request.script,
});
}
browser.runtime.onMessage.addListener(handleMessage);
ブラウザーの対応状況
Report problems with this compatibility data on GitHubdesktop | mobile | ||||||
---|---|---|---|---|---|---|---|
tabId |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
メモ:
この API は Chromium の chrome.devtools
API に基づいています。Microsoft Edge の互換性データは Microsoft Corporation によって提供され、Creative Commons Attribution 3.0 United States License に含まれています。