nodeca / tabex

Cross-tab message bus for browsers.
http://nodeca.github.io/tabex/
MIT License
219 stars 19 forks source link

Tabex with iframe doesn't work when loaded after DOMContentLoaded event #14

Closed Kukunin closed 7 years ago

Kukunin commented 7 years ago

Tabex, when configured with cross-domain via iframe, doesn't work when it was injected on the page after DOMContentLoaded event.

That's because this event was already fired, and won't fire never: https://github.com/nodeca/tabex/blob/master/lib/tunnel.js#L82, so no iframe is injected, no communication in tabex.

As possible fix we can check window.readyState and listen event only if it's loading.

puzrin commented 7 years ago

Honestly, i'm not strong in browser programming. Could you do PR with right check?

PS. Also see "known problems" in Readme. Cross-domain messaging will suck in Safary and IE.