Basically what i am trying to do is to detect number of frames which are contained within the G+ home page, and off course i do use a content script
The Js file for the extension:
var myIframes;
window.addEventListener('load'
,function()
{
//If the window location matches the G+ home page
//Log number of frames contained within it
if(window.location.href.match("https://plus.google.com/u/0/"))
{
console.log('G+ loaded');
myIframes = document.getElementsByTagName('iframe');
console.log(myIframes.length);
}
}
,false);
The o/p log of executing this code is:
G+ loaded
2
Now comes the strange part, when i try to access the myIframes variables length from within the inspector console, i got 8 frames.
So my question is “How come !.”, shouldn’t the myIframes variables stay as it was when it first get evaluated ?
document.getElementsByTagName('iframe')returns a nodeList.nodeLists are live, they will update when the DOM changes.