phpmyadmin/resources/js/modules/cross_framing_protection.ts
Maurício Meneghini Fauth 01e4a87bbd
Move resources/js/src to resources/js
Signed-off-by: Maurício Meneghini Fauth <mauricio@mfauth.net>
2025-05-22 13:43:59 -03:00

31 lines
729 B
TypeScript

declare global {
interface Window {
allowThirdPartyFraming: boolean | string;
}
}
/**
* Conditionally included if framing is not allowed.
*/
const crossFramingProtection = (): void => {
if (window.allowThirdPartyFraming) {
return;
}
if (window.self !== window.top) {
window.top.location = window.self.location;
return;
}
const styleElement = document.getElementById('cfs-style');
// check if styleElement has already been removed to avoid frequently reported js error
if (typeof (styleElement) === 'undefined' || styleElement === null) {
return;
}
styleElement.parentNode.removeChild(styleElement);
};
export { crossFramingProtection };