Redirection using php and javascript

Published

Here is how you can redirect your current page to a  new declared url. suing php and javascript at the same time.
If you are using this script in iframe, it will help you to open page in the parent page,and not inside the iframe.

<?php
$redirecturl='http://aslamise.blogspot.com';
echo "<script type='text/javascript'>window.open('$redirecturl', '_parent', '')</script>";
?>


Code Explained

<?php
$redirecturl='http://aslamise.blogspot.com'; //Assigning the redirect url
echo "
<script type='text/javascript'>
window.open('$redirecturl', '_parent', '')//Window.open = Opening the window in the specified address
                                                            $redirecturl= The Url we assigned just before.
                                                             _parent =opening on the main.even if the script goes inside iframe-
                                                              It will be opened in main window and not inside iframe.
</script>
";
?>

Javascript function used

window.open()

Comments

Post a Comment