domingo, 6 de febrero de 2011

New chrome tab with dynamic content injection

To create a new chrome tab and inject content dynamically on it you need to use:
  • chrome.tabs.create: on main script 
  • chrome.tabs.sendRequest: on main script
  • chrome.extension.onRequest: on new tab
Take a look at the API doc for more info: 

Main script
chrome.tabs.create({url: "NewTabView.html"}, 
 function (tab) {
  // Callback function is called when tab is created.
  chrome.tabs.sendRequest(tab.id, {content: "hello tab"}
 );
});


NewTabView.html





No hay comentarios:

Publicar un comentario