0

I have a HTML page that can be opened in a different iframe depending on some conditions. In page execution I need to know in what iframe the page is running. How can I do this?

/* Page A: */
if (openinA)
  $("#frameA").attr("src", "pageb.php");
else
  $("#frameB").attr("src", "pageb.php");

/* Page B: */
// Which IFRAME i am?
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
eluc
  • 1
  • 2
  • you can probably find info here https://stackoverflow.com/questions/3420004/access-parent-url-from-iframe (Access parent URL from iframe) .. but there are tons of restrictions – Diego D Dec 22 '22 at 10:11
  • 1. jQuery is not the right tool for this, as it's a framework primarily for manipulating the DOM, not getting references to parent pages. Use plain JS. 2. See the duplicate for the answer. – Rory McCrossan Dec 22 '22 at 10:33

0 Answers0