Mr. Black Posted February 2, 2003 Share Posted February 2, 2003 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 More sharing options...
0 Nxt_Gate Posted February 2, 2003 Share Posted February 2, 2003 try this.. echo " <script language = 'JavaScript'> window.location.replace('toobusy.htm') </script>"; Link to comment Share on other sites More sharing options...
0 Mr. Black Posted February 3, 2003 Author Share Posted February 3, 2003 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 More sharing options...
0 Nxt_Gate Posted February 3, 2003 Share Posted February 3, 2003 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 More sharing options...
0 Redmak Administrators Posted February 4, 2003 Administrators Share Posted February 4, 2003 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 More sharing options...
0 Mr. Black Posted February 4, 2003 Author Share Posted February 4, 2003 Is there any way to have the page re-direct without the Address bar changing to the new URL? Link to comment Share on other sites More sharing options...
0 Nxt_Gate Posted February 4, 2003 Share Posted February 4, 2003 i htink you should use frames for that Link to comment Share on other sites More sharing options...
0 Mr. Black Posted February 4, 2003 Author Share Posted February 4, 2003 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 More sharing options...
Question
Mr. Black
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