Adam Merrifield
Adam Merrifield

Reputation: 10407

Detect if the url in an iFrame has changed

Is there anyway to detect if a user clicks a link inside of an iframe if the iframe is not on the same domain as the parent page?

EDIT: I don't have access to the iframed page. I only own the parent window.

Upvotes: 0

Views: 738

Answers (3)

digitalbath
digitalbath

Reputation: 7334

No. Due to the javascript same-origin policy, you cannot access any members of the iframe's DOM if the iframe did not serve from the same domain as the page on which your javascript is running.

Upvotes: 1

ShankarSangoli
ShankarSangoli

Reputation: 69905

Try this.

var isInSameDomain = (window.location.host == window.parent.location.host);

Upvotes: 0

jbabey
jbabey

Reputation: 46647

if (window.domain !== top.domain) {
  // they are not the same
}

Upvotes: 1

Related Questions