Luke Harby asked me in Mastodon:
I am trying to write a bookmarklet but once I have it working I need to target an iframe, not sure if that is going to be possible, but I will endeavour to find out.
Iframe is on the same domain at least.
He said the magic words in the second paragraph: same domain.
If you have a web page that includes an iframe from the same domain (or more specifically, they are of Same Origin), you can access the DOM through with HTMLIFrameElement.contentDocument:
Once the iframe has loaded (in this use case, Luke was building manually triggered bookmarklet so no need for programmatic wait), you can access it with
If the iframe is in a different domain, contentDocument
returns null
.