JavaScript Archives - Ian Carnaghan

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...

Mar 20 · 1 min read >

How to redirect to a page using Javascript

window.location.href = 'redirect.html';

Mar 20 · 1 sec read >

How to check if a value is a number or not a number using JavaScript

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...

Mar 20 · 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...

Mar 20 · 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

Mar 20 · 3 sec read >

How to change the src (url) of a IFrame using JavaScript

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

Mar 20 · 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...

Mar 20 · 13 sec read >

How to disable and enable HTML form fields using JavaScript

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

Mar 20 · 8 sec read >

How to get the file extension from a filename using Javascript

var filename = 'myFile.jpg'; var ext = filename.split('.').pop();  //We split the filename on every instance where the . is...

Mar 20 · 7 sec read >