Preventing Third-Party iframe Embedding
Website owners often face the issue of their pages being embedded within frames (iframes) on third-party websites. While the referrer request header proves ineffective in detecting this scenario during page loading, there are several approaches to address this problem.
JavaScript Detection
After the page loads, JavaScript can be employed to detect if it is being displayed within a frame. By comparing the top and self properties, one can determine if the page is embedded. If they differ, the page is within an iframe.
X-FRAME-OPTIONS Header
Some modern browsers support the X-FRAME-OPTIONS header, which offers two options:
Browsers such as Picasa respect this header and prevent embedding from third-party websites.
Browser Support for X-FRAME-OPTIONS Header
Browsers that support X-FRAME-OPTIONS with their minimum versions include:
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3