Next page | Contents page |

Move to an IDE - localhost

Some of the things we are covering in this part of the course will prevent browsers running our files from a local disc, on the grounds of security. This will certainly happen when we get to manipulating pixels in images. Browsers really expect the HTML and JavaScript to come from a server. However, we can quite easily set up a lightweight local server so we still do not need to go online to run our programs.

The IP address 127.0.0.1 is special. It refers to the current computer and will use a "localhost" server if one is available. Further explanation is in this Wikipedia article.

To make this work we need to move our program writing from a simple text editor to an IDE (Integrated Development Environment). There are many of these available. I use Netbeans which is completely free and very reliable. It was designed for Java programming but it has plug-ins for various programming languages. There is a good plug-in for HTML5 which includes full support for JavaScript (in several different environments, not just browsers).

You will need to create a new project, as an "HTML5/JS application". One of the options is to import existing files as a new project, if you wish to do that. You will also need to look at project properties to select your browser for run-time. Otherwise there is nothing essential to set up.

A major benefit of using an IDE rather than a plain text editor is that it will be checking your syntax as you type, giving warnings and error messages as necessary and also suggesting functions to use. That can save a lot of time.

In Netbeans, and I expect in all IDEs that support HTML5/JS, selecting to "run" your HTML file causes the necessary localhost facilities to be set up and your HTML page and scripts will be seen in whichever browser you selected for your project.

Next page | Contents page |