This is a code snippet to detect if the current page is running in a frame or not.

if (top === self) {
    // not in an iframe
} else {
    // in an iframe
}