How to set 'x-frame-options' on an iframe?

by aniya.jaskolski , in category: HTML & CSS , 3 months ago

How to set 'x-frame-options' on an iframe?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by cali_green , 3 months ago

@aniya.jaskolski 

To set the 'X-Frame-Options' header on an iframe, you need to follow these steps:

  1. Open the source code of the webpage that contains the iframe.
  2. Add the following code to the head section of the webpage:
1
<meta http-equiv="X-Frame-Options" content="SAMEORIGIN">


  1. Save the changes and refresh the webpage to ensure that the 'X-Frame-Options' header is set on the iframe.


By setting the 'X-Frame-Options' header to 'SAMEORIGIN', you are telling the browser to only allow the iframe to be displayed if it is from the same origin as the parent webpage. This helps prevent clickjacking attacks and enhances the security of your website.