Javascript: Creating a basic popup window

Javascript gives you the ability to open new windows in you’re browser. You’ll also have the ability to run any code in these windows,...
Ian Carnaghan
1 min read

How to redirect to a page using Javascript

window.location.href = 'redirect.html';
Ian Carnaghan
1 sec read

How to check if a value is a number…

By using the isNaN() JavaScript function. isNaN = Is Not A Number Examples: document.write(isNaN(“Hello World!”)); //Will print true since Hello World! is not a number document.write(isNaN(123456)); //Will print false, since 123456 is...
Ian Carnaghan
11 sec read

How to encode a URL in JavaScript

There are two JavaScript function that you can use to accomplish this  encodeURIComponent() Encodes a URI component Encodes special characters The following characters: ,...
Ian Carnaghan
12 sec read

How to refresh an IFrame using Javascript

var iframe = document.getElementById('iframe_id'); iframe.src = iframe.src; iframe_id is the ID of the IFrame
Ian Carnaghan
3 sec read

How to change the src (url) of a IFrame…

document.getElementById('iframe_id').src = 'newpage.html iframe_id = The ID for the IFrame newpage.html = The page that you want to load into the IFrame
Ian Carnaghan
5 sec read

How to set a timer in JavasScript

If we want to call a function every 10 seconds using JavaScript we can accomplish it by implementing the following piece of code window.setInterval('yourfunction()',...
Ian Carnaghan
13 sec read

How to disable and enable HTML form fields using…

To enable a form field use the below JavaScript document.getElementById("ELEMENT_ID").disabled = false; And to disable the form field use the below JavaScript document.getElementById("ELEMENT_ID").disabled =...
Ian Carnaghan
8 sec read

How to get the file extension from a filename…

var filename = 'myFile.jpg'; var ext = filename.split('.').pop();  //We split the filename on every instance where the . is found and then getting the...
Ian Carnaghan
7 sec read