How can I detect in a view function that the page is being loaded in an iFrame? I want to change the page slightly if that is the case. Is there any way to do this?
Note, Im not looking for click jacking protection. I want to make changes to my view if the page is being loaded in an iframe.
You can check the {{ request.META.HTTP_SEC_FETCH_DEST }}
variable in the template. Example:
<section id="header" class="hero is-small is-info {% if request.META.HTTP_SEC_FETCH_DEST != 'document' %}is-hidden{% endif %}">
List of possible values for HTTP_SEC_FETCH_DEST: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Sec-Fetch-Dest
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