bars > Ja, du må over i JavaScript for at gøre det!
Brug evt. dette:
function SmartLoad($getVarString = '', $loadUri= '')
{
if (strlen($loadUri) > 0) { // Did the user want to load another page?
$location = $loadUri; // Set the URI to be loaded to the one passed by the user ($getVarString is ignored)
} else {
$location = '
http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); // Set the URI to be loaded to the absolute URI of the current page
if (strlen($_SERVER['QUERY_STRING']) > 0) { // Is there any GET-vars?
$location .= '?' . $_SERVER['QUERY_STRING']; // If yes - include GET-vars
}
if (strlen($getVarString) > 0 && strlen($_SERVER['QUERY_STRING']) > 0) { // Did the user want to add GET-vars?
$location .= '&' . $getVarString; // Concatenate with en ampersand if there were already GET-vars
} elseif (strlen($getVarString) > 0) {
$location .= '?' . $getVarString; // Concatenate with a question mark if not
}
}
if (headers_sent() != false) { // Is any output sent to the client?
print "\n\n<script language=\"javascript\" type=\"text/javascript\">\n// <![CDATA[\n\tdocument.location.href = \"" . addslashes($location) . "\"; // Load new URI\n// ]]>\n</script>\n\n"; // If yes - load the page with JavaScript (this does not close <html>-tags etc...)
} else {
header('Location: ' . $location); // If no output is sent, the client will be redirected with header()
}
exit; // Terminate the script after redirection
}
/*
void SmartLoad([string getVarString [, string loadUri]])
This function will send an HTTP location-header with a new URI if no output has been sent to the browser. Otherwise it will print a JavaScript, which will load the new URI.
The URI is the URI of the current script if loadUri is empty. If getVarString is set it will be put at the end of the original URI. Multiple GET-vars should be separated with an ampersand (e.g.: 'var1=val1&var2=val2').
If an URI is passed to loadUri the user will be sent to this location. getVarString is not taken into consideration, since GET-vars can just be passed in loadUri.
// Example; SmartLoad()
SmartLoad('newGETvar=true&anotherGETvar=someValue'); // Will reload the page with two new GET-vars - the reload-method depends on already sent headers
SmartLoad('', '
http://www.jensgram.dk'); // Will load
www.jensgram.dk - the method still depends on already sent headers (anything passed to the first parameter (getVarString) is ignored!)
*/