0

Let's say that I've got a page in an iframe.

So...

top page {
iframed page{
}
}

Now, I want to give the iframe page an id.

From within the code on the iframed page, can I check to see if the value of the id of the iframed page is equal to something?

if ($('#iframeid', window.parent.document))

doesn't seem to work.

1 Answers1

0

If it's Chrome or Firefox, you should be able to do:

 window.frameElement.id

inside the iframe to get the id of the iframe itself.

dave
  • 62,300
  • 5
  • 72
  • 93
  • why only Chrome of Firefox? – Christophe Nov 20 '13 at 21:49
  • according to https://developer.mozilla.org/en-US/docs/Web/API/Window.frameElement Opera and Safari may not support it. Apparently IE does support it though, didn't notice that (most likely because I dont care about IE) – dave Nov 20 '13 at 21:52