Skip to content

Instantly share code, notes, and snippets.

@DeveloperWil
Created August 26, 2014 16:37
Show Gist options
  • Select an option

  • Save DeveloperWil/2872519c2fdf7cbf0dbe to your computer and use it in GitHub Desktop.

Select an option

Save DeveloperWil/2872519c2fdf7cbf0dbe to your computer and use it in GitHub Desktop.
JS PHP redirect function. Use when Headers have already been output to screen
function lc_js_redirect($url, $seconds=1){
echo "<script language=\"JavaScript\">\n";
echo "<!-- hide from old browser\n\n";
echo "function redirect() {\n";
echo "window.location = \"" . $url . "\";\n";
echo "}\n\n";
echo "timer = setTimeout('redirect()', '" . ($seconds*1000) . "');\n\n";
echo "-->\n";
echo "</script>\n";
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment