I'm currently working on a Chrome extension but I got stuck.. I'm trying to manipulate a textarea with the Chrome extension. If I put in a value directly, the code works fine, but if I want to get the value from a variable it won't work..
This code WORKS:
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.executeScript({
code: 'document.getElementById("message").value = "Hello!";'
});
});
This code DOESN'T WORK:
carName = "Volvo";
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.executeScript({
code: 'document.getElementById("message").value = carName;'
});
});
Can someone tell me what's wrong and how I should do it right?
Thanks in advance