I'm building a chrome extension and I need to read the HTML code of the current selection in background.html I can get the text selection from background.html:
function(info,tab) {
var text = info.selectionText;
}
But I need the HTML code. From inside background.html I tried:
var selection = window.getSelection();
var range = selection.getRangeAt(0);
var container = range.commonAncestorContainer;
var html = container.innerHTML
But I believe I can't access the window object from inside background ...
I did read SpikeX post: Get page selection including HTML? but not couldn't find the source code he's referring to...
Thanks!
M