'Get the new src of a redirected iFrame before it redirects

I'm trying to get the new src of an iFrame on redirect, and run a function before it redirects (using the redirected src). For example, if the original url of the iFrame is https://example.com/, which redirects to https://example.com/otherpage, I want to run a function doSomething('https://example.com/otherpage') before otherpage is actually loaded.

I've already tried using onload="doSomething(this.src)", but that gives me the original url (in this case https://example.com/), not the new one.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source