Document.Open()不起作用
Document.Open() is not work
所以,我有一个按钮,如果用户的用户名和密码正确,它会通知你,然后重定向到另一个页面。第一件事是有效的,但它不会将您重定向到页面。
这是网页的代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Siur</title>
<script type="text/javascript">
///////////////////////////Login System///////////////////////////
function getCookie(){
var whole, username, password, splitting, actual,user, pass;
whole = document.cookie;
whole = whole.split(';');
username = whole[0];
password = whole[1];
actual = password.split('=');
user = actual[0];
pass = actual[1];
alert(user + password);
}
function setCookie(c_name,value,exdays){
var c_value=value + ";
pass="+document.getElementById('passwordText').value;
document.cookie="=" + value + ";
pass="+document.getElementById('passwordText').value;
alert(document.cookie);
getCookie();
}
function url(url){
document.open(url);
}
function checkCookie(){
var whole, username, password, splitting, actual,user, pass;
whole = document.cookie;
whole = whole.split(';');
username = whole[0];
password = whole[1];
actual = password.split('=');
user = actual[0];
pass = actual[1];
if (document.getElementById('usernameText').value !=null &&
document.getElementById('usernameText').value!="" &&
document.getElementById('passwordText').value == pass) {
alert("Welcome again " + user);
document.open('search_webpage.html');
}
else{
alert('Incorrect username or password.');
}
}
//////////////////////////////End of Login system////////////////////////////////////
</script>
</head>
<body>
<table width=100% height=30 background="nav.png" border="0">
<tr>
<td >
<form id="form1" name="form1" method="post" action="">
<label for="searchBox"></label>
IN-DEV 0.1
</form>
</td>
</tr>
</table>
<img src="logo.png" width="206" height="147" />
<p>-Where everything is at your finger tips-</p>
<p>
<label for="usernameText"><label>Username: </label></label>
<input type="text" name="usernameText" id="usernameText" />
</p>
<p>
<label for="passwordText"><label>Password: </label></label>
<input type="password" name="passwordText" id="passwordText" />
</p>
</center>
<center>
<input type="submit" name="create" id="create" onclick="checkCookie()" value="Login" />
<input type="submit" name="check" id="check" onclick="setCookie(
document.getElementById('usernameText').value,
document.getElementById('passwordText').value,365);" value="Register" />
</p>
<p><a href="http://blacklist.eff.org/">Fight SOPA now!</a></p>
<p><!--[if lt IE 7]>
<div style=' clear: both; height: 59px; padding:0 0 0 15px; position: relative;'> <a href="http://windows.microsoft.com/en-US/internet-explorer/products/ie/home?ocid=ie6_countdown_bannercode">
<img src="http://storage.ie6countdown.com/assets/100/images/banners/warning_bar_0000_us.jpg" border="0" height="42" width="820" alt="You are using an outdated browser. For a faster, safer browsing experience, upgrade for free today." />
</a></div> <![endif]--><footer><font color="#CCCCCC">Copyright 2012, All Rights Reserved.</font></footer></p>
</center>
</body>
</html>
document.open()
不用于转到新的URL。当您使用document.write()
时会调用它。它将清除当前页面。
您要使用window.location = 'http://example.com';
。
首先,使用同时引用函数的变量名通常不是一个好主意。我在您的基本HTML代码中观察到了很多问题,因为第一阶段本身试图编写正确的代码并遵循最佳实践。
对于以下
function url(url){
document.open(url); //is url the function or the variable?
}
使用如下
function goto_url(url) {
window.location.href = url; //I think this might be what you are looking for
}
另一方面,使用javascript验证用户密码就像银行在同意兑现支票之前询问你的支票是否有效。
很抱歉,我指的是window.location.href
,但如果他们点击后退按钮,可能会导致历史循环。。也许使用window.location.replace(url)
更好
相关文章:
- Windows.Open 在 window.Location 工作时不起作用
- window.open(url).print()在Safari中不起作用
- Javascript window.open()toolbar=no不起作用
- window.open()在使用phone gap的iOS应用程序上不起作用
- window.open在chrome中不起作用
- js window.open and print 在 google chrome 中不起作用
- AIR HTMLLoader window.open 不起作用
- Window.open() 在 Multiple if 条件中不起作用
- Window.open 在包含确认对话框的 if 条件中不起作用
- Javascript window.open on link 在 PHP 中不起作用
- window.open 在 IE8 中不起作用
- jQuery Mobile $(“#popup”).popup(“open”);转换页面后不起作用
- window.open() 在 IE11 中不起作用
- window.open()在ajax中不起作用
- Javascript onclick window.open不起作用
- window.open()在JSP中传递变量时不起作用
- window.open在IE10中不起作用
- Document.Open()不起作用
- Javascript Onclick window.open Popup在Firefox和Safari中不起作用
- win1=不同函数中的window.open和win1.close()不起作用