I'm displaying my site (www.example.com
) inside of an iFrame of another site, let's say www.example.org
. I have to load different content on my page when iFrame is loading on a certain subpage of this site, so it should load on:
www.example.org/subpageA
www.example.org/subpageB
But shouldn't load when the site URL on which it's loaded is equal to www.example.org/subpageC
I tried using document.location.ancestorOrigins[0]
for this, but it's returning only "www.example.org"
(without the path), no matter which subpage I am, so I can't define when this certain subpage is loaded. How can I collect the full path of the source page from which my site is loaded in an iFrame, including the /subpageC part?