views:

39

answers:

1

This is really irritating. I have looked over the code continuosly but I cannot see why I am getting "undefined" thrown at me.

<html>
 <head>
  <link href="../../style.css" rel="stylesheet" type="text/css">
  <script type="text/javavscript">
   function test()
   {
    alert("yey");
   }
  </script>
 </head>

 <body>
  <div id="L1" onmouseover="javascript:test()">Test</div>

 </body>
</html>

I am using Chrome 6.0.472.55 to test this.

+4  A: 

Maybe because you have a typo in the script's type:

<script type="text/javavscript">

should be

<script type="text/javascript">

the browser will not interpret language types unknown to it.

Pekka
Wow, I can't believe how stupid of a mistake that is. Thank you - I had spent all day trying to find that stupid mistake. GRR
Rarge
@Rarge, some will disagree, but arguably you don't even need the "text/javascript". See the answer at http://stackoverflow.com/questions/2706290/why-write-script-typetext-javascript-when-the-mime-type-is-set-by-the-server/2706364#2706364
brainjam