how to check if page is in iframe 1

how to check if page is in iframe

if ( window.location !== window.parent.location ) {
  // The page is in an iframe
} else {
  // The page is not in an iframe
}

Here is what the above code is Doing:
1. First, we check if the window.location is the same as the window.parent.location.
2. If it is, then we know that the page is not in an iframe.
3. If it isn’t, then we know that the page is in an iframe.

Similar Posts