OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Web BroadcastChannel fails in iframe when src is redirected

  • Thread starter Thread starter meerlol
  • Start date Start date
M

meerlol

Guest
I have an iframe with src attr set to https://example.com/path. This URL redirects 301 to https://othersite.com/path. This page loads some JS and creates a BroadcastChannel with a listener on it. It then opens a new window to https://othersite.com/path2. This page load some JS that creates a BroadcastChannel with the same name and does a postMessage. The problem: it never arrives in the iframe. The weird thing is, it does work if the src of the iframe is not a redirect. But that doesn't make sense because even though it is redirected, the origin is determined by the page that is eventually loaded. So the origins are the same (yes I checked that), and the BroadcastChannel names are the same. So why doesn't this work??

<p>I have an iframe with src attr set to <a href="https://example.com/path" rel="nofollow noreferrer">https://example.com/path</a>. This URL redirects 301 to <a href="https://othersite.com/path" rel="nofollow noreferrer">https://othersite.com/path</a>. This page loads some JS and creates a BroadcastChannel with a listener on it. It then opens a new window to <a href="https://othersite.com/path2" rel="nofollow noreferrer">https://othersite.com/path2</a>. This page load some JS that creates a BroadcastChannel with the same name and does a postMessage. The problem: it never arrives in the iframe. The weird thing is, it does work if the src of the iframe is not a redirect. But that doesn't make sense because even though it is redirected, the origin is determined by the page that is eventually loaded. So the origins are the same (yes I checked that), and the BroadcastChannel names are the same. So why doesn't this work??</p>
 

Latest posts

Top