What if you want to check if your page is hosted in an i-frame and may be prevent certain features?
On the network side, you can pass a response header from your server that looks like this:
X-Frame-Options: DENY header prevents your page to be accessed in an i-frame altogether.
X-Frame-Options: SAMEORIGIN header allows the page to load if the parent (wrapping window) of the i-frame is of the same origin, which is somewhat OK.
But if you do not have a header provided by your server and you still want to check if you are inside an i-frame, you may do the following conditional check.
Alright, I hope this helps.