javascript not working from notepad++

2.2k views Asked by At

I am having trouple with my javaScript not running in Waterfox for a standard .html file i made using notepad++

Below is my JavaScript

document.getElementByID("foot01").innerHTML = "<p>;  " + new Data().getFullYear() + " Extra Technical, Out of this world.</p>";

and below is the section of HTML in my file that calls this Jscript

<footer id="foot01"></footer>
</div>
<script type="javascript" src="script.js"></script>

What is the issue here and how can i fix it, i made sure that all is spelt correctly and still cant figure it out.

3

There are 3 answers

0
Quentin On
<script type="javascript" src="script.js"></script>
              ^^^^^^^^^^

That is not a MIME type. It should be application/javascript (or text/javascript for compatibility with older browsers). But the type attribute is optional, so just remove it entirely as the only purpose it serves (when you are writing JS) is to allow you make typos that break the script.

A validator should have picked that up.

getElementByID

That is not how you spell Id, which needs a lower-case d. JavaScript is case sensitive.

Data().getFullYear()

That is not how you spell Date, which ends in an e not an a.

0
HamS89 On

use : new Date().getFullYear()

not new data()

0
Lokesh Yadav On

You made two of those mistakes. Correct those two and it will work smooth.

document.getElementById("foot01").innerHTML = "<p>" + new Date().getFullYear() + " Extra Technical, Out of this world.</p>";

Fiddle - http://jsfiddle.net/ylokesh/5j1w12vk/

To identify these issues, you should open developer tools in browser window. You will get clear definition of errors in console. That will save your time to resolve small mistakes.