Check out this quick and user-friendly solution using vanilla JavaScript. With just a single line of code in JS, you can easily customize the appearance through CSS/SASS/LESS.
To implement this, insert the following code snippet within the head
section before loading any CSS or JS:
// Dynamically assigns a class to the HTML element using vanilla JavaScript
document.documentElement.className += (window.self == window.top ? " top" : " framed");
Now, in your CSS/SASS/LESS files, you can modify the layout, visibility, and styles based on the applied class.
/* Conceal website navigation when running within an iframe */
html.framed .site-nav,
html.framed .site-footer {
display: none;
}
Important note: It's advisable to utilize the X-Frame-Options for security purposes and prevent unauthorized usage of your content.