I'm trying to make a Chrome Extension that will take some of the contents of a page (The inner HTML of a <span>
with id="productTitile"
) I then would need to take that value and put it into a field in my popup.html.
I have tried this:
document.getElementById('input_87').value = chrome.tabs.executeScript({
code: 'document.getElementById("productTitle").innerHTML'
});
But it just returns undefined
into the field. I then ran document.getElementById("productTitle").innerHTML
in the console in the parent page, and it gave me the expected value, but when I ran the whole code in console of the popup extension, it again returned undefined.
What am I doing wrong?