I need to display a link if the current page is being viewed in parent browser window, or display another link if window is being viewed inside an iframe. How can i do that via php? Something like:
if (self == top)
echo '<span><a href="./" >Link1</a></span>';
else
echo '<span><a href="./index.php">Link2</a></span>';
edit: since it cant be done with php, i still looking for similar solution, maybe JS, can someone pls tell me how?
Final edit: The answer:
echo '
<script type="text/javascript">
if(window === top) {
document.write("<span><a href=\"./\">go-to-frame</a></span>");
}
else {
document.write("<span><a href=\"./index.php\">go-to-top</a></span>");
}
</script>
';
thank you all.