I know that this topic has already been solved, and a few years later I came to this, I personally just used an example from Joan's answer and changed it to work exactly as I need it, as location.href does not redirect TOP or parent page when called inside iframe.
So, for those who are looking for a way to redirect after 5 seconds, but inside the iframe and redirect the TOP / Parent page, here is how I achieved this based on Joan's answer to the original question.
<script type="text/javascript"> setTimeout(function(){window.top.location="index.php"} , 5000); </script>
And if you want to call it using PHP, as I personally did here, this is how you would use the echo command to redirect the user in 5 seconds.
echo '<script type="text/javascript">setTimeout(function(){window.top.location="index.php"} , 5000);</script>';
Hope this helps someone else find the same solution.
thanks
Birdy
source share