Javascript Step by Step JavaScript is the most popular scripting language on the internet, and works in all major browsers, such as Internet Explorer, Firefox, Chrome, Opera, and Safari. Before you continue you should have a basic understanding of the following: HTML / XHTML. What Is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is […]
A cookie is often used to identify a user. Cookies are small amounts of data or information stored by the web browser. They allow us to store particular information about a user and retrieve it every time they visit our pages. Each user has their own unique set of cookies. What is a Cookie? A […]
Javascript Time Clock Display a clock on your web page. <html> <head> <script type=”text/javascript”> function startTime() { var today=new Date(); var h=today.getHours(); var m=today.getMinutes(); var s=today.getSeconds(); // add a zero in front of numbers<10 m=checkTime(m); s=checkTime(s); document.getElementById(‘txt’).innerHTML=h+”:”+m+”:”+s; t=setTimeout(‘startTime()’,500); } function checkTime(i) { if (i<10) { i=”0″ + i; } return i; } </script> </head> <body […]
The Date object allows you to work programatically with dates and times. You create a Date object using the Date constructor.The Date object contains 17 functions. The Date object The Date class is used to store and retrieve dates in JavaScript. To create a Date object, we can use the following techniques given bellow. new […]
JavaScript Browser Detection Java Script browser detection is based on the “navigator” object, which could just be thought of as the browser. Browser Properties Java Script defines eight properties browsers can report: Browser Properties Description appCodeName Specifies the code name of the browser. appName Specifies the name of the browser. appVersion Specifies version information for […]
JavaScript Functions A function will be executed by an event or by a call to the function.To keep the browser from executing a script when the page loads, you can put your script into a function. A function contains code that will be executed by an event or by a call to the function. You may […]
JavaScript Throw Statement The throw statement generates an error condition that can be handled by a try…catch statement. The throw statement allows you to create an exception. The throw statement allows you to create an exception. If you use this statement together with the try…catch statement, you can control program flow and generate accurate error […]
JavaScript Try…Catch Statement The try…catch statement allows you to test a block of code for errors. JavaScript – Catching Errors When browsing Web pages on the internet, we all have seen a JavaScript alert box telling us there is a runtime error and asking “Do you wish to debug?”. Error message like this may be useful for […]
JavaScript For…In Statement The for…in statement is used to loop (iterate) through the elements of an array or through the properties of an object. The for…in statement iterates a specified variable over all the properties of an object. For each distinct property, JavaScript executes the specified statements. A for…in statement looks as follows: Syntax for (variable in […]
There are two special statements in JavaScript that can be used inside loops: break and continue. Break Statement We Use the break statement to terminate a loop, switch, or label statement. When we use break without a label, it terminates the innermost enclosing while, do-while, for, or switch immediately and transfers control to the following […]