Skip to content

Instantly share code, notes, and snippets.

@liamegan
Created August 17, 2017 15:33
Show Gist options
  • Save liamegan/ca4fd0f89b786bee5eb9be6892362322 to your computer and use it in GitHub Desktop.
Save liamegan/ca4fd0f89b786bee5eb9be6892362322 to your computer and use it in GitHub Desktop.
Find all iframes and show their details. Intended for the console.
document.querySelectorAll('iframe').forEach((iframe)=> {
console.log(iframe.id, iframe.className, iframe.src)
});
@nelisjunior
Copy link

Thanks, man!

@aquaductape
Copy link

aquaductape commented Mar 26, 2024

I wonder if browsers optimize this search. Rather than using the traditional query by searching through every dom node and check if tag is iframe, which could be slow, maybe the browser holds a reference to all browsing contexts/embeds and returns that. Therefore the amount dom nodes is no longer a factor because it's just ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment