rashcroft22
rashcroft22

Reputation: 57

find out if iframe url has been changed

Is there a way for me to find out if the URL in my iframe has been changed, ie, the user has navigated somewhere? Thanks.

Upvotes: 2

Views: 2515

Answers (2)

Sinan
Sinan

Reputation: 11563

yourIframeName.onbeforeunload = function () {
  //do something
}

This will trigger your function just before navigating to another page on iframe.

This behaves weird on somebrowsers though.

Upvotes: 2

Mercurybullet
Mercurybullet

Reputation: 889

A similar question over here has some answers that should help you out. If you keep track of where the iframe starts, you can then use the methods in that link to see if it has changed.

Upvotes: 2

Related Questions