Skip to content Skip to sidebar Skip to footer

Redirect If The Page Is Iframe

Here is what i want to do: in my blog, comments are shown in a fancybox popup using iframe. (eg:- for the post number 2, comments link open an iframe fancybox comments.php?id=2) I

Solution 1:

Put this script in your page. If it is not opened in a frame, it will redirect to post.php?id=...

<scripttype="text/javascript">if (parent.location==location) {
        location.href = "post.php" + location.search;
    }
</script>

Solution 2:

I am thinking something like

if ( document.parent.frames.length > 0 ) {
    document.parent.location = "post.php";
}

should work

Post a Comment for "Redirect If The Page Is Iframe"