JavaScript Location.replace 不起作用
javascript location.replace doesn't work
我有这个代码:
<?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一直告诉我,我应该在我的帖子中添加更多细节,但我认为这就是我能提供的所有细节。
您需要
通过从单击处理程序返回false
来阻止提交表单的默认操作
echo '<input type="submit" onclick="LinkAdded(); return false;" name="wget-send" value="Send" id="WgetID"/>';
相关文章:
- 替换变量时,JavaScript字符串replace()不起作用
- 使用replace方法替换innerHTML以及在Javascript中不起作用的正则表达式
- string.replace(“é”, “e”) 不起作用
- .replace 在 for 循环中不起作用吗?
- JavaScript Location.replace 不起作用
- YouTube ajax, .replace() 不起作用
- window.location.replace() 在窗体中不起作用
- JavaScript .replace() 部分的 url 不起作用
- 字符串正则表达式模式.replace(/{0}/, “$0.00”) 不起作用
- 使用window.location.replace重定向不起作用
- window.location.replace不起作用
- Javascript Regex replace在IE10中不起作用
- window.location.replace在客户端不起作用
- 如果重新加载了同一页,window.location.replace将不起作用
- Javascript replace()方法不起作用
- 试图更改onchange中的所有数字-onchange.replace没有'不起作用
- replace()函数在ie浏览器中不起作用
- Javascript中的Replace All不起作用
- 当我试图通过rails插入URL时,window.replace方法在js中不起作用
- Parameters .replace()两次jQuery插件不起作用