0

Let's say I have the following iframe on my website:

<iframe id="my-frame" src="www.espn.com"></iframe>

If someone where to interact the iframe and make a change where the URL inside of the iframe updated its parameters for example:

www.espn.com?q=TEAMS:cowboys

Is there a way to capture the updated URL from the iframe or the new parameters?

To give you an idea of what I am trying to do in my mind it would look something like this:

var myFrame = document.getElementById("my-frame");

myFrame.addEventListener('change', (event) => 
    // get URL from iframe after the URL has changed
    // example: www.espn.com?q=TEAMS:cowboys
);

is this possible?

  • did you check this ? https://stackoverflow.com/questions/2429045/iframe-src-change-event-detection – Hadrien Lejard Nov 22 '20 at 11:26
  • Thanks for the reply! I gave this a go, but there are security issues in-lining onLoad in the html it seems. This must have changed since this was posted. I will see if I can find a way to work around this though and report the results! – pi-r-squared Nov 23 '20 at 17:29

0 Answers0