Pass variables to current tab via chrome extension

Posted by iamthejeff on Stack Overflow See other posts from Stack Overflow or by iamthejeff
Published on 2010-04-23T16:20:57Z Indexed on 2010/04/23 16:23 UTC
Read the original article Hit count: 303

I am writing my first chrome extension, and I want to pass a variable to the currently opened tab and manipulate the DOM with it.

My extension has a button, and when clicked, is executing this code:

chrome.tabs.getSelected(null, function(tab) {
 chrome.tabs.executeScript(tab.id, {
  file: 'tabscript.js'
 });
});

This works fine, but I see no way to pass a variable to tabscript.js so it can be used on the opened tab.

© Stack Overflow or respective owner

Related posts about google-chrome-extension

Related posts about JavaScript