Science Oxford Logo

Advanced - Adding Javascript

These instructions show you how to add a javascript file to your website, by using some example countdown timer code.

You can use this javascript example in your website, but these instructions do not show you how to write your own javascript program.


Example

This example code sets a countdown timer using Javascript, and runs it using HTML in our index.html file.


Switch the the 'countdown.js' file and look at line 4 - this is where you set the date to count down to!

It is currently set to "Jun 26, 2021 16:00:00" - try changing it to, for example, your birthday.


Now switch tabs back to index.html. Lines 14 & 15 run the Javascript file.


How could you use the countdown timer in your own website?


Make your Own

If you have some previous coding experience, and would like to write your own Javascript programs, you can find more information on w3schools.com.