![]() |
#2
elan19862010-11-25 16:22
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www. <head> <title>ex1</title> <style type="text/css"> *{margin:0} body {text-algin:center;min-width:760px} div{padding:3px 3px 3px 3px} #main {width:720px;margin:0 auto;text-algin:left;margin-top:30px} </style> <link type="text/css" rel="stylesheet" href="style1.css" id="style1" title="蓝色风格" /> <link type="text/css" rel="stylesheet" href="style2.css" id="style2" title="红色风格" /> <link type="text/css" rel="stylesheet" href="style3.css" id="style3" title="灰色风格" /> <link type="text/css" rel="stylesheet" href="style4.css" id="style4" title="字体小" /> <link type="text/css" rel="stylesheet" href="style5.css" id="style5" title="字体中" /> <link type="text/css" rel="stylesheet" href="style6.css" id="style6" title="字体大" /> <script type="text/javascript"> function setCSS(){ setColor($("setColor").value); setSize($("setFontSize").value); } function $(id){ return document.getElementById(id); } function setColor(color){ $("style1").disabled = true; $("style2").disabled = true; $("style3").disabled = true; $(color).disabled = false; } function setSize(size){ $("style4").disabled = true; $("style5").disabled = true; $("style6").disabled = true; $(size).disabled = false; } function SetCookie(cookName,cookieValue,nDays){ var today=new Date(); var expire=new Date(); if(nDay==null||nDays==0) nDay=1; expire.setTime(today.getTime()+3600000*24*nDay); document.cookie=cookieName+"="+escape(cookieValue)+"expires="+expire.toGETString(); } function login(){ var username=$("user").value; var password=$("pass").value; var save=$("save").checked; if(username == '' || password == ''){ alert('请录入用户名或密码'); return; } if(username == '1' && password == '1'){ if(save) SetCookie("username",username,7); else Setcookie("username",username,1); }else{ alert("用户名错误!"); } /* if(username=="test" && password="password"){ if(save) SetCookie("username",username,7); else Setcookie("username",username,1); document.location="ex2.html"; }else{ alert("用户名错误!"); } */ } function register(){ } function $(id){ return document.getElementById(id); } </script> </head> <body> <table border="0"> <tr> <td> </td> <td><select id="setColor"> <option value="style1" checked>蓝色</option> <option value="style2">红色</option> <option value="style3">灰色</option> </select> <select id="setFontSize"> <option value="style4" checked>小</option> <option value="style5">中</option> <option value="style6">大</option> </select> <input type="button" id="set" value="设置提交" onClick="setCSS();" /> </td> </tr> <div id="main"> <div> <span>用户名:</span><input type="text" id="user" /></div> <div> <span>密码:</span><input type="password" id="pass" /></div> <input type="checkbox" id="save"> 7天无需登录 <input type="button" onclick="login();" value="登录"/> <input type="button" onclick="register();" value="注册"/></div> </div> </table> </body> </html> |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<title>ex1</title>
<style type="text/css">
*{margin:0}
body {text-algin:center;min-width:760px}
div{padding:3px 3px 3px 3px}
#main {width:720px;margin:0 auto;text-algin:left;margin-top:30px}
</style>
<link type="text/css" rel="stylesheet" href="style1.css" id="style1" title="蓝色风格" />
<link type="text/css" rel="stylesheet" href="style2.css" id="style2" title="红色风格" />
<link type="text/css" rel="stylesheet" href="style3.css" id="style3" title="灰色风格" />
<link type="text/css" rel="stylesheet" href="style4.css" id="style4" title="字体小" />
<link type="text/css" rel="stylesheet" href="style5.css" id="style5" title="字体中" />
<link type="text/css" rel="stylesheet" href="style6.css" id="style6" title="字体大" />
<script type="text/javascript">
function setCSS(){
setColor($("setColor").value);
setSize($("setFontSize").value);
}
function $(id){
return document.getElementById(id);
}
function setColor(color){
$("style1").disabled = true;
$("style2").disabled = true;
$("style3").disabled = true;
$(color).disabled = false;
}
function setSize(size){
$("style4").disabled = true;
$("style5").disabled = true;
$("style6").disabled = true;
$(size).disabled = false;
}
function SetCookie(cookName,cookieValue,nDays){
var today=new Date();
var expire=new Date();
if(nDay==null||nDays==0) nDay=1;
expire.setTime(today.getTime()+3600000*24*nDay);
document.cookie=cookieName+"="+escape(cookieValue)+"expires="+expire.toGETString();
}
function login(){
var username=$("user").value;
var password=$("pass").value;
var save=$("save").checked;
if(username=="test"&&password="password"){
if(save) SetCookie("username",username,7);
else Setcookie("username",username,1);
document.location="ex2.html";
}
else{
alert("用户名错误!");
}
}
function $(id){
return document.getElementById(id);
}
</script>
</head>
<body>
<table border="0">
<tr>
<td> </td>
<td><select id="setColor">
<option value="0">阅读底色</option>
<option value="style1">蓝色</option>
<option value="style2">红色</option>
<option value="style3">灰色</option>
</select>
<select id="setFontSize">
<option value="0">字体大小</option>
<option value="style4">小</option>
<option value="style5">中</option>
<option value="style6">大</option>
</select>
<input type="button" id="set" value="设置提交" onClick="setCSS();" />
</td>
</tr>
<div id="main">
<div>
<span>用户名:</span><input type="text" id="user" /></div>
<div>
<span>密码:</span><input type="password" id="pass" /></div>
7天无需登录
<input type="button" onclick="login()" value="登录"/>
<input type="button" onclick="register()" value="注册"/></div>
</div>
</table>
</body>
</html>
为何不能用,看看还有什么问题要改正