The code above is fine. You should have no issues setting a hashchange event listener on the iframe's window. The problem is that you are viewing the console for the parent window. For example, if you change your console.log to an alert, you will see that it is in fact working.
If you're using google chrome's developer tools, you can click on this drop-down to switch between which window context you are in: