Programming Tips - Javascript: detect if you are inside an iframe

Date: 2020mar17
Language: javaScript

Q.  Javascript: detect if you are inside an <iframe>

A.

function inIframe () { try { return window.self !== window.top; } catch(ex) { return true; } }