ya****@gmail.com wrote:
My HTML is shown in an iframe. There is a link in the HTML that needs
the ID of the iframe to be used in the onclick event. How do I get it?
By now there is wide support for
window.frameElement
so e.g.
if (window.frameElement) {
alert(window.frameElement.id);
}
will do in recent IE and Mozilla and Opera.
IE's documenation is here:
<http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/properties/frameelement.asp>
Supported there since IE 5.5.
I can't tell you the exact Mozilla and Opera versions from which on this
is supported.
You can always walk up to the parent window and parent.document and look
through the iframe elements.
And somehow your request sounds as if all you want is e.g.
<iframe name="frameName" src="whatever.html"></iframe>
and
<a href="whatelse.html" target="frameName">link</a>
but perhaps you really need script.
--
Martin Honnen
http://JavaScript.FAQTs.com/