为什么JavaScript URL表单无法工作,也无法重定向
Why JavaScript URL form is not working nor redirecting?
我正在用PHP制作一个服务,它创建一个在输入字段中键入名称的文件夹。
我尝试拼凑一些JavaScript,使页面重定向到您刚刚创建的文件夹(以及名为toggle.php的文件)这是我的JavaScript:
<?php
function recurse_copy($src,$dst) {
$dir = opendir($src);
@mkdir($dst);
while(false !== ( $file = readdir($dir)) ) {
if (( $file != '.' ) && ( $file != '..' )) {
if ( is_dir($src . '/' . $file) ) {
recurse_copy($src . '/' . $file,$dst . '/' . $file);
}
else {
copy($src . '/' . $file,$dst . '/' . $file);
}
}
}
closedir($dir);
}
$src = "./xe7";
$dst = $_POST['foldername'];
recurse_copy($src,$dst);
?>
<link rel="stylesheet" type="text/css" href="style.css" />
<div>
<body onload="timer=setTimeout('removeControls();',3)">
<h1>Drawblog</h1>
<div class="FAQ" style ="box-shadow: 1px 1px 3px rgba(0,0,0,0);">
<a href="#hide1" class="hide" id="hide1">Control panel</a>
<a href="#show1" class="show" id="show1">-</a>
<div class="list" style ="box-shadow: 1px 1px 3px rgba(0,0,0,0);">
<form method="post" >
<input type="text" name="foldername" id ="togl">
<input type="submit" name="submit" id = "sm2" value="Create panorama" onclick ="newDoc();">
<script type="text/javascript">
function newDoc() {
var folder = document.getElementById("togl").value;
var url = "http://hokuco.com/test/" + folder + "/toggle.php";
window.location.assign(url)
};
</script>
</form>
<h3>Or,</h3>
<h2>Login with an access code(the account you just typed into the box above, or a code someone shared with you)</h2>
<input type="text" id="field" />
<button id="submit">Go</button>
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript">
document.getElementById("submit").addEventListener("click", function(){
var folder = document.getElementById("field").value;
var url = "http://hokuco.com/test/" + folder + "/index.html";
window.location.href = url;
});
</script>
</div>
</div>
<h1> </h1>
<h1> </h1>
<p>make shocking panoramas in minutes, no account needed</p>
<br/>
<br/>
<br/>
<br/>
<p>special thanks to:</p>
<div id="info"><a href="http://threejs.org" target="_blank">three.js css3d</a> - panorama.</div>
<h5>a hokuco company</h5>
</div>
<style>
.FAQ {
vertical-align: top;
height:auto !important;
}
.list {
display:none;
height:auto;
margin:0;
float: left;
}
.show {
display: none;
}
.hide:target + .show {
display: inline;
}
.hide:target {
display: none;
}
.hide:target ~ .list {
display:inline;
}
/*style the (+) and (-) */
.hide, .show {
width: 45px;
height: 30px;
font-size: 20px;
color: #000;
text-shadow: 0 1px 0 #666;
text-align: center;
text-decoration: none;
background: #ffffff;
opacity: .95;
border-bottom: thick solid #000000;
margin-right: 0;
float: left;
margin-bottom: 25px;
}
.hide:hover, .show:hover {
text-decoration: none;
opacity: 1;
color: #000;
background: #ffffff;
margin-bottom: 25px;
}
.list p{
height:auto;
margin:0;
}
.question {
float: left;
height: auto;
width: 90%;
line-height: 20px;
padding-left: 20px;
margin-bottom: 25px;
}
</style>
<form id="form">
<input type="text" id="mysearch-text">
<input type="submit" value="Submit">
<script>
window.onload = function () {
document.getElementById("form").onsubmit = function () {
var filmName = document.getElementById("mysearch-text").value;
alert(filmName);
if (filmName == "parker") window.location.href = "http://www.w3fools.com";
else alert("hello");
return false; //prevent the default behavior of the submit event
}
}
相关文章:
- 通过链接重定向不;我不在jstree中工作
- 意思是.js - 登录后重定向用户 - 在本地工作,但在部署时不起作用
- JavaScript没有'JSP页面重定向后无法工作..任何解决方案
- 带有SetTimout的Javascript重定向不工作
- window.location重定向没有'我不在IE8上工作
- 基于变量的Javascript URL重定向无法正常工作
- 为什么JavaScript URL表单无法工作,也无法重定向
- JavaScript警报重定向无法正常工作
- co重定向无法正常工作
- 角度重定向到其他方式而不检测视图,但当我单击后退按钮时它可以工作
- 轮播在初始重定向时中断,但在刷新时工作正常
- JavaScript重定向它不是在服务器上工作,而是在本地主机上工作
- HTML POST->重定向工作,XMLHTTPrequest->重定向不起作用(无法从null发出任何请求
- Javascript重定向:symfony路由中的脚本不工作
- 如果语句重定向未按预期工作
- CORS重定向工作异常
- 404重定向工作在当前目录
- 多个iFrame重定向工作,但考虑PHP的安全性
- Javascript重定向工作在chrome,但不是IE
- PHP头文件("location: test.php")不工作.但是java脚本重定向工作