Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Due to prerendering and other factors, tabs can be 'replaced'. This means that tabId can change even if you keep the tab open. <code>chrome.webNavigation.onTabReplaced</code> can be used to capture such events. See <a href="https://developer.chrome.com/extensions/webNavigation.html#event-onTabReplaced" rel="nofollow">https://developer.chrome.com/extensions/webNavigation.html#event-onTabReplaced</a> for more information.</p> <p>To demonstrate this, following these steps <em>may</em> help:</p> <ol> <li>Make sure that you've requested "tabs" and "webNavigation" request for your extension and your extension doesn't use a non-persistent background page (without background.persistent = true in manifest.json). Also make sure Google is your default search engine and Instant Search is enabled.</li> <li>Open some website (not Google search).</li> <li>Execute <code>chrome.tabs.query({}, function(tabs){console.log(tabs)})</code> in the developer tools of your extension's background page. Look at existing tabs and their ids.</li> <li>Execute <code>chrome.webNavigation.onTabReplaced.addListener(function(details){console.log(details);</code> in the DevTools.</li> <li>Type something in the omnibox of that tab to trigger Google Instant and click on the body of the page. You should see the onTabReplaced event fired and the old and new tab ids in the console of the DevTools.</li> <li>Execute <code>chrome.tabs.query({}, function(tabs){console.log(tabs)})</code> again and you'll find that tab id actually 'changed'.</li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload