craftymind
09-26-2003, 10:21 PM
Can anyone please tell me why this works in all browsers
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Resize Div</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript">
function setHeight(divid, newH){
document.getElementById(divid).style.height = newH;
}
</script>
</head>
<body>
<div align="center">
<div id="resize" style="width:400px; height:200px; background-color:#FF0000;"></div>
<input type="button" onclick="setHeight('resize', 400)" value="Enlarge" />
</div>
</body>
</html>
but changing the doctype/encoding to xhtml doesn't work in non-IE browsers
<?xml version="1.0" encoding="UTF-8"?>
<!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" xml:lang="en" lang="en">
<head>
<title>Resize Div</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript">
function setHeight(divid, newH){
document.getElementById(divid).style.height = newH;
}
</script>
</head>
<body>
<div align="center">
<div id="resize" style="width:400px; height:200px; background-color:#FF0000;"></div>
<input type="button" onclick="setHeight('resize', 400)" value="Enlarge" />
</div>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Resize Div</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript">
function setHeight(divid, newH){
document.getElementById(divid).style.height = newH;
}
</script>
</head>
<body>
<div align="center">
<div id="resize" style="width:400px; height:200px; background-color:#FF0000;"></div>
<input type="button" onclick="setHeight('resize', 400)" value="Enlarge" />
</div>
</body>
</html>
but changing the doctype/encoding to xhtml doesn't work in non-IE browsers
<?xml version="1.0" encoding="UTF-8"?>
<!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" xml:lang="en" lang="en">
<head>
<title>Resize Div</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript">
function setHeight(divid, newH){
document.getElementById(divid).style.height = newH;
}
</script>
</head>
<body>
<div align="center">
<div id="resize" style="width:400px; height:200px; background-color:#FF0000;"></div>
<input type="button" onclick="setHeight('resize', 400)" value="Enlarge" />
</div>
</body>
</html>