Saad Awan Saad Awan - 5 months ago 16x
PHP Question

get width height of iframe content

hi i want if any one use my url on iframe my code detected the ifame and also its size

<iframe name="test" src="" style="border: 0; position:absolute; top:0; left:0; right:0; bottom:0; width:100%; height:100%" scrolling="no" border="0" frameborder="0"></iframe>

if any one use like
on iframe my
file detect it use our url on iframe and his sizes also.
can its possible? please tell me how to do it


In your iframe you need to add the script:

if (window !== top) {
  alert(window.innerWidth + ',' + window.innerHeight);

This script check if your page run in iframe: (window !== top)

Then alert the width and height.



For prevent website to embed yours, the best way I know is in the server.

Just return the header X-FRAME-OPTIONS: DENY.

The X-Frame-Options HTTP response header can be used to indicate whether or not a browser should be allowed to render a page in a , or . Sites can use this to avoid clickjacking attacks, by ensuring that their content is not embedded into other sites.