0
我有這樣的代碼:的JavaScript location.replace不工作
<?php
include 'theme.php';
css();
if($_POST['wget-send'])
{
$formdir=$_POST['dir'];
$formlink=$_POST['link'];
$filelink = fopen('/root/wget/wget-download-link.txt',a);
$filedir = fopen('/root/wget/wget-dir.txt',w);
fwrite($filedir, $formdir);
/*
fwrite($filelink, $formlink."\n");
exec('touch /root/wget/wget-download-link.txt',$out);
exec('echo "'.$dir.'" > /root/wget/wget-dir.txt',$out);
*/
exec('echo "'.$formlink.'" > /root/wget/wget-download-link.txt');
exit();
}
echo "<form action=\"".$PHP_SELF."\" method=\"post\" id=\"WgetForm\">";
echo "Download directory:<br><input type=\"text\" name=\"dir\" size=\"15\" value=\"/mnt/usb/\"/><br>";
echo '<br>Download link:';
echo ("<textarea name=\"link\" rows=\"13\" cols=\"62\"></textarea><br><br>");
echo '<input type="submit" onclick="LinkAdded()" name="wget-send" value="Send" id="WgetID"/>';
echo "</form></div>";
echo <<<HTML
<script type="text/javascript">
function LinkAdded()
{
alert("Link has been sucessfully sent to wget, it'll be downloaded soon, check the wget log for the download progress");
location.replace("wget_log.php");
}
</script>
HTML;
foot();
echo '
</div>
</body>
</div>
</html>';
?>
的alert
部分作品它給了我一個彈出,但彈出後,它只是給我一個空白頁。如何讓location.replace("wget_log.php");
工作?
stackoverflow不斷告訴我,我應該在我的帖子中添加更多細節,但我認爲這就是我可以提供的所有細節。
爲什麼不只是下降的JavaScript,並設置'action'形式爲'wget_log.php'返回
false
防止提交表單的默認操作,你在做什麼沒有意義? – adeneo,因爲它也不起作用 – orlea