Frame Integrity Checker
Verify your site's structure with precision. This advanced script doesn't just check for the presence of a frame; it validates that the parent window is your specific frameset, preventing your content from being improperly embedded elsewhere.
Integrity Logic
The Security Check:
if (window.parent.name != 'main_frameset')
This script specifically looks at the name attribute of the parent window. If a competitor frames your site, their frame will not have this specific name, triggering the protection mechanism.
Copy the Script
<script>
// Frame Integrity Checker
// Replace 'main_frameset' with the actual NAME attribute of your frameset tag
if (window.parent.name != 'main_frameset') {
// If the parent name is incorrect, redirect to the homepage
window.location.href = "index.html";
}
</script>
Note: Ensure you have named your frameset in your <frameset> or <iframe> tags using the 'name' attribute for this script to function.
Frequently Asked Questions
A basic script just asks 'Am I in a frame?'. This script asks 'Am I in MY frame?'. It checks the name or URL of the parent window to prevent being framed by external or incorrect sites.
The script will treat the situation as if the page is unframed (or wrongly framed) and trigger a redirect to your primary index page or specific frameset loader.
Yes. You can target specific levels of the window hierarchy (e.g., using 'parent.parent' or 'top') to ensure the complex nested structure is intact.