1

My JavaScript in head wont execute. I have tried excluding alot of things to try and figure out why my JavaScript wouldn't execute with anything i had. I have come to the conclusion that my JavaScript won't execute. At the moment I only have a blank alert that should say "Loaded" but even that won't load.

This is the what I have in my code at the moment

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1   /DTD/xhtml1-strict.dtd">
    <html lang="nl" xml:lang="nl" xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-type" content="text/html; charset=Windows-1252" />
    <meta content="Windows-1252" http-equiv="encoding" />
    <meta http-equiv="Content-Language" content="nl" />
    <title>Micha J</title>
    <script src="http://code.jquery.com/jquery-1.8.3.js" type="text/JavaScript" />
    <script type="text/JavaScript"> 
    //<![CDATA[

        alert("Ready");

        //]]>
    </script>
    <link href="style.css" type="text/css" rel="stylesheet">
</head>

Hopefully someone will be able to help me with my problem and get it working.

Hello
  • 77
  • 1
  • 13
Vyxisprime
  • 13
  • 3

1 Answers1

8

You can't self-close <script>. Use a full closing </script> tag here:

<script src="http://code.jquery.com/jquery-1.8.3.js" type="text/javascript"></script>
<script type="text/javascript"> 
  alert("Ready");
</script>

See squadette's answer citing the XHTML 1 specification

Community
  • 1
  • 1
Antiga
  • 2,264
  • 1
  • 20
  • 28