I am working on a chrome extension that can find a request comes from which iframe. Now I can get a frameId by listen to chrome.webRequest so I can get frameId(see the frameId section in the link, not the id attribute in iframe tag).
Can I use this frameId to find the iframe? What I want is only retrieve the iframe tag's attribute like name, width and height.
Thanks
Here is my working code base on Xan's answer below.
//frameScript.js
(function() {
var body = document.body,
html = document.documentElement;
var height = Math.max( body.scrollHeight, body.offsetHeight,
html.clientHeight, html.scrollHeight, html.offsetHeight );
var width = Math.max( body.scrollWidth, body.offsetWidth,
html.clientHeight, html.scrollWidth, html.offsetWidth );
return {
width: width,
height: height
}
}());
//background.js
chrome.tabs.executeScript(currentTabId, {
allFrames: true,
file: 'frameScript.js'
}, function(data) {
console.log(data);
});