Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

access iframe name from inside iframe

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> 
like image 864
Ilia Choly Avatar asked Feb 12 '10 00:02

Ilia Choly


People also ask

How do I access the inside iframe?

Getting the element in Iframeconst iframe = document. getElementById("myIframe"); Now, it has and contentWindow property which returns the document object by using that we can access the elements from an Iframe. const iWindow = iframe.

How do I get an iframe title?

How to get a click iframe title ID #frame and pass in $('#test title'). text('Here Titley frame'); JavaScript.

Can you access iframe content?

You could use . contents() method of jQuery. The . contents() method can also be used to get the content document of an iframe, if the iframe is on the same domain as the main page.


1 Answers

There is a combination of answers I prefer:

// window.frameElement Gets IFrame element which document inside window.frameElement.getAttribute("Name"); 

It works on IE7+, Mozilla & Chrome

like image 116
efirat Avatar answered Sep 17 '22 11:09

efirat