By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,567 Members | 1,185 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,567 IT Pros & Developers. It's quick & easy.

DOCTYPE puzzle

P: n/a
Hi all.

I'm testing the following page:

<html><head>
<title>DHTML Test</title>
<script language="JavaScript">
isW3C = false;
isNS = false;
isIE = false;
function BrowserCheck() {
if (document.layers) { // NS 4 DOM
isNS = true;
}
else if (document.all && !document.getElementById) { // IE 4 DOM
isIE = true;
}
else if (document.getElementById) { // W3C standards-compliant DOM
isW3C = true;
}
if (isW3C) {
isNS = (navigator.appVersion.charAt(0)>=4 &&
(navigator.appName).indexOf("Netscape") != -1);
isIE = (navigator.appVersion.charAt(0)>=4 &&
(navigator.appVersion).indexOf("MSIE") != -1);
}
}

function init() {
BrowserCheck();
if (isW3C) {
block = document.getElementById("blockDiv").style;
} else {
if (isIE) {
block = blockDiv.style;
} else {
if (isNS) {
block = document.blockDiv;
document.captureEvents(Event.KEYDOWN | Event.KEYUP);
}
}
}
alert(block.clip);
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,50px,100px,0px);
visibility:visible; background-color:red; layer-background-color:red;">Test
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
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Alex NSB" <al*****@tin.it> wrote in message
news:bq**********@newsread.albacom.net...
<BODY onLoad="init()">
<DIV ID="blockDiv" NAME="blockDiv" STYLE="position:absolute; left:50px;
top:80px; width:100px; height:100px; clip:rect(0px,50px,100px,0px);
visibility:visible; background-color:red; layer-background-color:red;">Test 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?


Yes. According to W3C, there should be
clip:rect (0px 50px 100px 0px)

instead of

clip:rect(0px,50px,100px,0px).
Jul 20 '05 #2

P: n/a
> Yes. According to W3C, there should be
clip:rect (0px 50px 100px 0px)

instead of

clip:rect(0px,50px,100px,0px).


Thank you very much: it was driving me crazy!

Alessandro
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.