WebRef.eu  - Internet Marketing and Online Business Resources  

Home / Site Map | Contact


Javascript Notes

Notes on how to code with Javascript.

Javascript is an event-driven language.

Javascript Variable Declaration

Declare a variable x equal to 5:

var x = 5;


How to Add A Javascript Script to Your Page

Javascript is put into script tags, and can be put in the head section of your html page. Below is a simple example that will display an alert when the page is loaded. Note we have not used a function, so it does not need to be called and will run by default when the page is loaded.

Here's the full web page code:

<!doctype html>

<meta charset="utf-8">
<title>Javascript Simple Alert Example</title>
<script language="javascript">
alert("Hi there, welcome to this page.")


<p>Javascript simple alert example page.</p>



See working example.

JavaScript Comments

// Single line comment

Multiline comment 1
Multiline comment 2
Multiline comment 3

JavaScript Or Operator



Method that returns the element that has a given id.


innerHTML Property

The HTML content of an element.

The innerHTML property sets or returns the HTML content (inner HTML) of an element.


Javascript Back

<a href='javascript:history.go(-1)'>back</a>

Javascript Refresh Page

<input type="button" value="Refresh Page" onClick="window.location.reload()">


<a onClick="window.location.reload()">Refresh</a>

Javascript Status Bar Masking

<a href="http://www.youraffiliate link" onMouseOver="window.status='your text here!'; return true" onMouseOut="window.status=''; return true">Click here</a>

Bookmark This Page Script

I found this example script at:


However, I found it to only provide an Add to Bookmarks pop-up in Firefox, so it does not add that much value to the user. Here's the working example.

JavaScript Fade Out Effect

See Demo JavaScript Fade Out

JavaScript Example - A Multiplication Table

JavaScript Multiplication Table

JavaScript Code Editors

Visual Studio Code
Includes built-in JavaScript IntelliSense, debugging, formatting, code navigation and refactorings.

JavaScript Tutorials and Resources

Microsoft Beginner's Video Series for JavaScript




Visit LowPrices.co.uk for Your UK Shopping


Low Prices UK Shopping

Compare Prices
at LowPrices.co.uk

Home / Site Map | Contact

All Content ©2020 WebRef.eu