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>
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 to get a click iframe title ID #frame and pass in $('#test title'). text('Here Titley frame'); JavaScript.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With