Couldn't you achieve the same effect using local storage?
Not sure best way but maybe:
On layout start -> set global variable to random number
On button -> store global variable into local storage, open new window
If global variable =! local storage then fire javascript
I actually haven't used local storage yet so doubt that is exactly how it would go but hopefully that conveyed the premise. I've used mySQL tables before and feel like I could achieve this with them, but figured local storage could as well and would be much simpler