Hi all.
I'm testing the following page:
<html><head>
<title>DHTML Test</title>
<script language="JavaS cript">
isW3C = false;
isNS = false;
isIE = false;
function BrowserCheck() {
if (document.layer s) { // NS 4 DOM
isNS = true;
}
else if (document.all && !document.getEl ementById) { // IE 4 DOM
isIE = true;
}
else if (document.getEl ementById) { // W3C standards-compliant DOM
isW3C = true;
}
if (isW3C) {
isNS = (navigator.appV ersion.charAt(0 )>=4 &&
(navigator.appN ame).indexOf("N etscape") != -1);
isIE = (navigator.appV ersion.charAt(0 )>=4 &&
(navigator.appV ersion).indexOf ("MSIE") != -1);
}
}
function init() {
BrowserCheck();
if (isW3C) {
block = document.getEle mentById("block Div").style;
} else {
if (isIE) {
block = blockDiv.style;
} else {
if (isNS) {
block = document.blockD iv;
document.captur eEvents(Event.K EYDOWN | Event.KEYUP);
}
}
}
alert(block.cli p);
alert(block.top );
}
</script>
</head>
<BODY onLoad="init()" >
<DIV ID="blockDiv" NAME="blockDiv" STYLE="position :absolute; left:50px;
top:80px; width:100px; height:100px; clip:rect(0px,5 0px,100px,0px);
visibility:visi ble; background-color:red; layer-background-color:red;">Tes t
div</DIV>
</body></html>
The two alerts in the init function are working fine (both IE6 and NS7) BUT
if I add the following line on top of the page
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
block.clip no longer works and the size of my div also seems wrong. Is this
the expected behaviour?
TIA for your help.
Alessandro
I'm testing the following page:
<html><head>
<title>DHTML Test</title>
<script language="JavaS cript">
isW3C = false;
isNS = false;
isIE = false;
function BrowserCheck() {
if (document.layer s) { // NS 4 DOM
isNS = true;
}
else if (document.all && !document.getEl ementById) { // IE 4 DOM
isIE = true;
}
else if (document.getEl ementById) { // W3C standards-compliant DOM
isW3C = true;
}
if (isW3C) {
isNS = (navigator.appV ersion.charAt(0 )>=4 &&
(navigator.appN ame).indexOf("N etscape") != -1);
isIE = (navigator.appV ersion.charAt(0 )>=4 &&
(navigator.appV ersion).indexOf ("MSIE") != -1);
}
}
function init() {
BrowserCheck();
if (isW3C) {
block = document.getEle mentById("block Div").style;
} else {
if (isIE) {
block = blockDiv.style;
} else {
if (isNS) {
block = document.blockD iv;
document.captur eEvents(Event.K EYDOWN | Event.KEYUP);
}
}
}
alert(block.cli p);
alert(block.top );
}
</script>
</head>
<BODY onLoad="init()" >
<DIV ID="blockDiv" NAME="blockDiv" STYLE="position :absolute; left:50px;
top:80px; width:100px; height:100px; clip:rect(0px,5 0px,100px,0px);
visibility:visi ble; background-color:red; layer-background-color:red;">Tes t
div</DIV>
</body></html>
The two alerts in the init function are working fine (both IE6 and NS7) BUT
if I add the following line on top of the page
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
block.clip no longer works and the size of my div also seems wrong. Is this
the expected behaviour?
TIA for your help.
Alessandro
Comment