你必须单独的JavaScript和HTML这样的:
?>
请注意,如果你想要做在PHP中一个普通的重定向(不把链接的图像上,但只是做手工)你不必做Javascript重定向(你不应该这样做,因为用户可以在浏览器中关闭javascript)。你可以做到这一点在PHP中:
header('Location: '.$your_url);
?>
*** UPDATE ***********
PHP文件:
//This will set a cookie for 1 hour named imageToOutput, change $path for the path you want to set
$path = '/my/file/path.png';
setcookie("imageToOutpout", $path, time()+3600);
header('Location: home.html');
?>
然后,在你的Home.html
注意,= ?>是一样的PHP做