Q:

How can I check if element is being loaded by iframe?

I have some 3rd party code (a knowledge base) that I need to load in an iframe on my site so I can display it in a popup modal, but when loaded via the popup I need to hide a few elements. Because it's coming from a different domain I can't run any code on the main site to hide the elements, which means my solution is to conditionally hide that code from within the 3rd party application (I can modify the display html/js/css from the 3rd party).
Is there any way I can run a check with js or css on the 3rd party code to check if it's being loaded in an iframe?

A:

From the third party JS inside the iframe, you can check the window.parent property to see if it is embedded in some other page.
From MDN for window.parent:

When a window is loaded in an <iframe>, <object>, or <frame>, its
  parent is the window with the element embedding the window.
If a window does not have a parent, its parent property is a reference to itself.

if (window.parent !== window) {
   // this window is embedded into something
}

