Detect iFrame embedding in Javascript

Solution 1:

Looking at frame length breaks down generally if page A itself has frames (I know this might not be the case for this specific instance). The more reliable and meaningful test would be:

if (window!=window.top) { /* I'm in a frame! */ }

Solution 2:

The predicate

(window.parent.frames.length > 0)

will tell you just what you want.