0

i'd like to know how a Javascript function can determine where it's being called from.

Can it figure out if it's being called from an iframe or another window?

Thank you so much.

Alejandro

AML
  • 1
  • 1
  • Does this answer your question? [How to identify if a webpage is being loaded inside an iframe or directly into the browser window?](https://stackoverflow.com/questions/326069/how-to-identify-if-a-webpage-is-being-loaded-inside-an-iframe-or-directly-into-t) – Oskar Grosser May 08 '21 at 17:05

1 Answers1

0

Calling a parent JS function from iframe is possible, but only when both the parent and the page loaded in the iframe are from same domain i.e. abc.com, and both are using same protocol i.e. both are either on http:// or https://

Read up more on CORS

  • Ok, let's suppose there are no CORS issues. How does the function determine where it's being called from? How can JS check which window called the function? That's my question. Thanks. – AML May 08 '21 at 14:19