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.

> You could just use a meta command (like this):

The W3C actually recommends against the use of such tricks for redirection. If Javascript is not a must, Digital Ether's suggestion seems good enough.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.