How can I get the topmost iframe which is in the same domain, i.e.
iframe level 1 example.org
iframe level 2 example.org
iframe level 2 example.org
iframe level 3 example.org <-- should return iframe level 1
iframe level 1 other-example.org
iframe level 2 example.org
iframe level 2 example.org
iframe level 3 example.org <-- should return iframe level 2
iframe level 1 other-example.org
iframe level 2 example.org
iframe level 2 example.org <-- should return iframe level 2 (this)
I need it because I have a website which should work in an iframe of another domain and stand-alone.
In this website there are scripts which depend on window.top which shouldn't be top but the topmost iframe in the same domain.