I though this would be simple enough but I can’t find the answer. I need to know how I can access an iframe’s name from within said iframe. I was trying something like this but it’s not working.
<iframe name="thename">
<script type="text/javascript">
alert(parent.name);
</script>
</iframe>
You were nearly right. Setting the
nameattribute on aframeoriframesets thenameproperty of the frame’s globalwindowobject to that string. (Notparent, which refers to the window of the document that owns the frame.)So unless some other script has deliberately changed the name, it’s as simple as: