(this is to add to the chosen answer)
Make sure the iframe
is loaded before you
contentWindow.document
Otherwise, your getElementById
will be null
.
PS: Can't comment, still low reputation to comment, but this is a follow-up on the chosen answer as I've spent some good debugging time trying to figure out I should force the iframe
load before selecting the inner-iframe element.