我已经参考了这两个问题call php page under Javascript function 和 Go to URL after OK button in alert is pressed。我想在警告框弹出后重定向到我的index.php。我的警告框在else语句中。以下是我的代码:
processor.php
if (!empty($name) && !empty($email) && !empty($office_id) && !empty($title) && !empty($var_title) && !empty($var_story) && !empty($var_task) && !empty($var_power) && !empty($var_solve) && !empty($var_result)) {
(some imagecreatefromjpeg code here)
else{
echo '<script type="text/javascript">';
echo 'alert("review your answer")';
echo 'window.location= "index.php"';
echo '</script>';
}
它没有显示任何内容(没有警告框,也没有重定向)。当我删除这部分echo 'window.location= "index.php"';
时,它会显示警告。但仍然无法重定向到index.php。希望您能帮助我解决这个问题。请不要将其标记为重复,因为我已经做了几篇相关的帖子作为参考。非常感谢您的帮助。
location.*
的问题。 - scrowler