Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing custom attribute from within an iframe



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

like image 863
Andreas Jarbol Avatar asked Apr 27 '26 14:04

Andreas Jarbol


1 Answers

Try this:

<script>
    alert(window.frameElement.getAttribute('customAttr'));
</script>
like image 70
putvande Avatar answered Apr 29 '26 02:04

putvande