Hi everybody,
I am using a java script function which redirect to the page according to the given parameter, and it is working as desired in IE, but I found that it not work with Firefox browsers, so some one plz guide me how it is possible to have the same function which could work on IE and Mozilla firfox.

The function code:

<?php
function reDirect($page)
{
     $s = "<script language = 'javascript'>
     window.navigate('$page');
     </script>";
     return $s;
}

Thanks

There is no navigate function for the window object. Maybe try something like:

<?php
function reDirect($page)
{
     $s = "<script language = 'javascript'>
     window.location.href = '$page';
     </script>";
     return $s;
}

Hi everybody,
I am using a java script function which redirect to the page according to the given parameter, and it is working as desired in IE, but I found that it not work with Firefox browsers, so some one plz guide me how it is possible to have the same function which could work on IE and Mozilla firfox.

The function code:

<?php
function reDirect($page)
{
     $s = "<script language = 'javascript'>
     window.navigate('$page');
     </script>";
     return $s;
}

Thanks

Unless there is a specific need for using javascript, you could redirect the browser using HTTP headers.

<?php

function reDirect($page)
{
     header("Location: $page"); // tell the browser to go to the new location..
     die; // die so we can flush http output immediately
}


?>

Isn't the die function the same as the exit function? Also, you can put a message to show people that the program is exiting
such as:
exit ('The program is exiting')
and
die ('The program is dying')

I believe they are the same.

The user would never see the message however under normal circumstances.

Its always good to add a bit of HTML explaining whats happening however, and add the JS that will redirect in case the browser fails to do a HTTP redirect.

This article has been dead for over six months. Start a new discussion instead.