Javascript does not seem to work in chrome

I'm having a tough time enabling javascript in chrome on my own webpage. Other websites seem to be able to do it pretty easily. Here's my prtty simple code but the start() function just wouldn't work.

<doctype html>
<html>
<head>
    <script type = "javascript">
        function start() {
            alert("Hi");
        }
    </script>
</head>
<body onload = "start()">
    Hi
</body>
</html>

Answers


The main problem is your type attribute. If you were to keep it, then it should be

<script type="text/javascript"></script>

However, you don't need it (See here: http://javascript.crockford.com/script.html). You can just use

<script></script>

That will fix your function.

Although not directly hindering your function, your doctype is missing the '!' and should probably be updated

<!doctype html>

You're using wrong type Attribute, it should be

<script type="text/javascript">

or simply

<script> </script>  //by default is type is "text/javascript"

Also change <!DOCTYPE html>


<!doctype html>
<html>
<head>
  <script>
        function start() {
            alert("Hi");           
        }
    </script>
</head>
<body onload = "start()">
    Hi
</body>
</html>

Need Your Help

Is it possible to have a pointer point a base class created by curiously recursive template?

c++ crtp

Is it possible to have a pointer point a base class created by curiously recursive template without using an interface ?

add data to column series in wpf C#

c# wpf charts

I want to create a ColumnSeries Bar Chart in WPF using C#.