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

Hi
I tried this javascript program in a HTML-page created in an asp.net 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?
Thanks
V

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


Answers (2)