DOCTYPE puzzle

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alex NSB

    #1

    DOCTYPE puzzle

    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


  • Vjekoslav Begovic

    #2
    Re: DOCTYPE puzzle

    "Alex NSB" <alexnsb@tin.it > wrote in message
    news:bqnpkq$gdu $1@newsread.alb acom.net...
    [color=blue]
    > <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;[/color]
    layer-background-color:red;">Tes t[color=blue]
    > div</DIV>
    > </body></html>
    >
    > The two alerts in the init function are working fine (both IE6 and NS7)[/color]
    BUT[color=blue]
    > 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[/color]
    this[color=blue]
    > the expected behaviour?[/color]

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

    instead of

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


    Comment

    • Alex NSB

      #3
      Re: DOCTYPE puzzle

      > Yes. According to W3C, there should be[color=blue]
      > clip:rect (0px 50px 100px 0px)
      >
      > instead of
      >
      > clip:rect(0px,5 0px,100px,0px).[/color]

      Thank you very much: it was driving me crazy!

      Alessandro


      Comment

      Working...