我有这段代码:
<?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一直告诉我,我应该在帖子上添加更多细节,但我认为这是我能提供的所有细节。
答案 0 :(得分:0)
您需要通过从点击处理程序返回false
来阻止提交表单的默认操作
echo '<input type="submit" onclick="LinkAdded(); return false;" name="wget-send" value="Send" id="WgetID"/>';