I am new to javascript.Itried to make this page but somehow shorten function does not work on providing doctype specification.I am using this one
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
but without specifcation it works fine
following is full code of file:<html>
<head>
<script language="javascript" >
function show(){
document.getElementById("dynamic").style.display="block";
document.getElementById("dynamic").style.opacity=1;
document.getElementById("dynamic").innerHTML="<table><tr>\n\t<td>Enter current password:</td><td><input type=\"password\" name=\"ppass\" size=\"45\"></td></tr><tr>\n<td>Enter new password:</td><td><input type=\"password\" name=\"npass1\" size=\"45\"></td></tr><tr>\n<td>Confirm password:</td><td><input type=\"password\" name=\"npass2\" size=\"45\"></td></tr><tr><td colspan=2><input type=submit value=\"Save\"></tr></table>\n";
document.setting.question[1].checked=true;
}
function hide(){
if(document.forms.setting.question[0].checked!=true){
fade("dynamic",50);
}
}
function appear(){
document.getElementById("dynamic").style.display="block";
document.getElementById("dynamic").style.opacity=1;
document.getElementById("dynamic").innerHTML="<table><tr>\n\t<td>Enter password:</td><td><input type=\"password\" name=\"ppass\" size=\"45\"></td></tr><tr><td>Security Question:</td><td><input type=\"text\" name=\"ques\" size=\"100\"></td></tr><tr><td>Answer:</td><td><input type=\"password\" name=\"ans\" size=\"10\"></td></tr><tr><td colspan=2><input type=submit value=Save></tr></table>";
document.setting.pass[1].checked=true;
}
function disappear(){
if(document.forms.setting.pass[1].checked){
slide("dynamic",50);
}
}
function fade(id,time){
var i=0;
for(;i<10;i++){
setTimeout("document.getElementById('dynamic').style.opacity-=0.1",(i*time));
}
i--;
setTimeout("gayab("+id+")",(i*time));
}
function gayab(id){
id.style.display="none";
id.innerHTML="";
id.style.opacity=1;
}
function slide(id,time){
var i=1;
document.getElementById(id).style.height=150;
var b=document.getElementById(id).style.height;
开发者_JS百科for(;i<15;i++){
var j="shorten("+id+","+i+")";
var k=i*time;
setTimeout(j,k);
}
var j="gone("+id+")";
var k=i*time;
setTimeout(j,k);
}
function shorten(id,i){
id.style.height=(15-i)*10;
}
function gone(id){
id.style.display="none";
id.style.height=150;
}
</script>
<noscript>You are Using an Outdated Browser.<br>Please Update Your Browser</noscript>
<style>
.options{float:left;}
#dynamic{float:right;background-color:rgb(210,205,236);height:150px;opacity:1;overflow:hidden;width:720px;display:none;}
.nofloat{clear:both;}
</style>
<title>Settings</title>
</head>
<body>
<p align=right><a href=home.php>HOME</a> <a href=newpass.php>Change Password</a> <a href=logout.php>Log Out</a></p>
<form action="changepass.php" method="post" name="setting">
<div class=options>
<table>
<tr>
<td>Change Password:</td>
<td><input type="radio" name="pass" onClick="show();" value="1" id="Yes"><label for="Yes">Yes</label></td>
<td><input type="radio" name="pass" onClick="hide();" value="0" id ="No" CHECKED><label for="No">No</label><br></td>
</tr>
<tr>
<td>Change Security Question:</td>
<td><input type="radio" name="question" onClick="appear();" value="1" id="yes"><label for="yes">Yes</label></td>
<td><input type="radio" name="question" onClick="disappear();" value="0" id="no" CHECKED><label for="no">No</label></td>
</tr>
</table>
</div>
<div id="dynamic"></div>
<div class=nofloat>
<a href=logout.php>Logout</a>
</div>
</form>
</body>
</html>
please help.
Your Doctype (despite being inappropriate for the document since it don't consist of a frameset) is triggering Standards mode.
This is a good thing as it massively reduces inconsistency between different browsers (and between browsers and standards).
In standards mode, most browsers will follow the CSS specification and treat things like height: 27
as an error to be ignored instead of an error to be corrected to height: 27px
.
The obvious problem with your code (there may be others, you have posted a lot of code) is that you are assigning numbers to CSS properties with JavaScript … and numbers don't have units.
To take just one example:
id.style.height=150;
should be:
id.style.height = "150px";
You make a similar mistake in at least one other place.
You are setting a document type which expects your page to consist of framesets, yet there are none there. You should use a different DOCTYPE
, for example transitional instead.
精彩评论