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 want to check whether comments.php is loaded in an iframe and if not, redirect to the respective blog page. ie post.php?id=2
I checked Google and other sites incl. stackoverflow. but no use. pls help. (this seems to be easy. but it ain't working http://www.onlineaspect.com/2009/06/10/reading-get-variables-with-javascript/
Put this script in your page. If it is not opened in a frame, it will redirect to post.php?id=...
<script type="text/javascript">
if (parent.location==location) {
location.href = "post.php" + location.search;
}
</script>
I am thinking something like
if ( document.parent.frames.length > 0 ) {
document.parent.location = "post.php";
}
should work
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.