• 0

Help w/ a window.location.replace line?


Question

if ( $avgs[1] < "1.00" && $avgs[1] >= "0.75" ) {
echo ( "<font color=green>■</font>□□□□□" );
}

I need to replace the entire echo line with a window.location.replace line so that if a load average is true, the page is replaced by a "Too busy" message, like on the Neowin forums here.

I was thinking:

echo ("javascript: window.location.replace('/toobusy.htm');"

Can anyone help me with this simple line replacement?

Thanks!

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

Hmmm, that didn't work (with the JS)

Can anyone give me a line that will redirect the page immediatly should the if...then value in PHP = true?

Link to comment
Share on other sites

  • 0

well you can use this function to redirect.....

function irPagina($url, $time = 0){

	if (!empty($url)) {
  if (@ereg("?", $url)) {
      $s_url = explode("?", $url);
 	 $s_parms = explode("&", $s_url[1]);

      while (list($key, $val) = each($s_parms)) {
        $data = explode("=", $val);
        $data[1] = rawurlencode($data[1]);
        $s_parms[$key] = join("=", $data);
      }

      $s_url[1] = join("&", $s_parms);
      $url = join("?", $s_url);
    }



    echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"$time; URL=$url\"> ";

  }
}

then you call the function like this: irPagina("./toobusy.htm",$seconds);

where $seconds is the time of redirecting.. if you want it inmediatly just dont use $sseconds (second paramenter),.... like next line!

irPagina("./toobusy.htm");

Link to comment
Share on other sites

  • 0

I think it's best to use a php solution like Nxt_Gate's

but here's something that should work with javascript

echo ("<script language = JavaScript>top.location.href='http://www.microsoft.com';</script>");

echo " <script language = 'JavaScript'> window.location.replace('toobusy.htm') </script>";

Worked for me as well btw

Link to comment
Share on other sites

  • 0

Can't.

This is a "server too busy" message script since my server doesn't show Apache 503 automatically.

It replaces the current content with a too busy msg, and as I said above, I don't want the address bar showing the different page.

It should be like Neowin.net, when you goto index.php for the forums, if the server is too busy, it displays a message like you are viewing index.php, it doesn't goto toobusy.htm from index.php.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.