[JS/DOM/HTML] Doctype zorgt voor onbenaderbare DOM propertie

Pagina: 1
Acties:

  • GigaDave56
  • Registratie: Juni 2001
  • Laatst online: 14-12-2025
Tijdens het updaten van een oude pagina loop ik tegen een probleem aan met onderstaande code. Zodra ik een HTML doctype toevoeg, werkt het javascript/DOM gedeelte niet meer, e.g. de DIV wordt niet meer verplaatst.

HTML:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
    <meta http-equiv="content-style-type" content="text/css">

    <link rel="stylesheet" href="style_45.css">

    <script type="text/javascript">
    function Size_Me()
    {
        document.getElementById("Menu_Caption").style.left = 120;
    }
    </script>

</head>
<body onload="Size_Me()">

    <!-- Set top menu 1 -->
    <div id="Menu_Caption" class="MenuCaption">
         My locations
    </div>

</body>
</html>

Cascading Stylesheet:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* General body setup */
body, { 
    cursor: default;
    font-family: tahoma;
    font-size: 11px;
    color: #FFFFFF;
    margin-left: 1;
    margin-top: 0;
    margin-bottom: 0;
    margin-right: 0;
}



/* Holds caption of menu */
div.MenuCaption
{
    position: absolute;
    top: 0px;
    width: 120px;
    height: 22px;
    color: #ffffff;
    background-color: #000000;
    border: 1px solid #ffffff;
    font-family: tahoma;
    font-size: 11px;
    display: inline;
    padding-left: 2px;
    padding-top: 2px;
}

De doctype code die ik toevoeg is: <!DOCTYPE HTML PUBLIC "­//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> maar ook strict geeft hetzelfde probleem.

Om mijn HTML/JS/CSS kennis bij te spijkeren gebruik ik http://www.w3schools.com. Hier heb ik niets gerelateerd kunnen vinden aangezien ze deze onderwerpen apart behandelen. Een zoekactie op GOT leverde als meest gerelateerde topics o.a. dit en dit op, maar die problemen waren niet terug te leiden op het toevoegen van een doctype.

Kan iemand mij een zetje in de richting van een oplossing geven?

Not so Giga One
> I'd sell my soul for you, babe
> For money to burn, for you
> I'd give you all and have none, babe
> Just to, just to, to have you here by me... [Scooter - Rebel yell]


  • crisp
  • Registratie: Februari 2000
  • Laatst online: 00:32

crisp

Devver

Pixelated

JavaScript:
1
document.getElementById("Menu_Caption").style.left = 120 + 'px';

Intentionally left blank


  • GigaDave56
  • Registratie: Juni 2001
  • Laatst online: 14-12-2025
Bedankt, Crisp. Had al zitten stoeien met [...].left = 120px; of [...].left = '120px'; wat ook niet werkte.

Not so Giga One
> I'd sell my soul for you, babe
> For money to burn, for you
> I'd give you all and have none, babe
> Just to, just to, to have you here by me... [Scooter - Rebel yell]