Valerie Meunier

Valerie Meunier

  • 827
  • 693
  • 75.8k

Javascript doesn't work with the line <!DOCTYPE html> in a html-page

Aug 24 2022 3:19 PM

I tried this javascript program in a HTML-page created in an web application (.Net Framework) in Visual Studio 2022. It doesn't work, I mean, the text remains at its original position.
But if i remove the first line <!DOCTYPE html>, then it works. Can somebody explain me how come?

<!DOCTYPE html>
<body onload="start()">
    <div ID="cc" STYLE="position:fixed">
        This is a text.
    <script type="text/javascript">
        var go = document.getElementById("cc").style;
        function start()
                go.left = 200;

Answers (2)