I need to match something outside of an iframe, and then something inside the iframe. Then I need to use these two matches to do something, but it seems I'm having trouble doing this.
Basically, when I tried to run this script, it first runs the entire script on everything outside of the iframe, and then it runs the entire script again on everything inside the iframe.
This results in me only getting one part of the match every time the script is ran, but I need both matches for this to work. Is there any way I can fix this?
console.log("this is the start-----------------------------------------------");
var insideIframe;
var outsideIframe;
html = document.getElementsByTagName('html')[0];
text = html.innerHTML;
matches = text.match(/match the things outside the iframe/);
if (matches) {
outsideIframe = matches[0];
} //end of if (matches)
console.log(outsideIframe);
matches = text.match(/match the things inside the iframe/);
if (matches) {
insideIframe = matches[0];
} //end of if (matches)
console.log(insideIframe);
console.log("this is the end-----------------------------------------------");
Results in console:
this is the start-----------------------------------------------
match the things outside the iframe
null
this is the end-----------------------------------------------
this is the start-----------------------------------------------
null
match the things inside the iframe
this is the end-----------------------------------------------