I would like to know if it is possible to get access a custom iframe attribute within the iframe.
I was thinking something along the lines of:
html1.html
<iframe src="html2.html" customAttr="example"></iframe>
html2.html
<script>alert(window.customAttr);</script>
However the variable window.customAttr appears undefined.
Does anyone know, how to get about this?
Regards
Try this:
<script>
alert(window.frameElement.getAttribute('customAttr'));
</script>
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