Apparently it's possible to access the iframe DOM object by name once you give it a 'name' attribute. If you type the name in chrome dev tools console, it will register the iframe object in the console.
That way you can also call JS methods from that iframe (see the onclick handler below).
How does it work? I mean, I thought name attribute only matters when it comes to forms - the server then is able to correctly read different fields that were set with a POST method for example. But here it makes a difference on the client side - it gives the ability to access the iframe and its functions. Does it work with iframes only? (If you try to get the code below to work locally you might get some errors, such as 'Blocked a frame with origin "null" from accessing a cross-origin frame', but I have a production code that does exactly that and it works fine.
.
<html>
<body>
<button id="fooButton" onclick="fooFrame.foo()">Click
</button>
<iframe id="fooFrame" name="fooFrame" src="./content.html">
</iframe>
<script>
console.log(fooFrame);
</script>
</body>
</html>