Tuesday, November 11, 2014

Use JavaScript to tell if the immediate web page sits within an iFrame or not.

This Stack Overflow thread offers:

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

 
 

...which seems to work pretty good.

No comments:

Post a Comment