EternallyCurious
EternallyCurious

Reputation: 2415

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>

Upvotes: 0

Views: 114

Answers (3)

Shaik Md N Rasool
Shaik Md N Rasool

Reputation: 500

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

Upvotes: 0

Zac Littleberry
Zac Littleberry

Reputation: 56

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>

Upvotes: 3

Praveen
Praveen

Reputation: 56509

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>

Upvotes: 10

Related Questions