Free Web Designing Courses

Free web designing tutorials, web designing tools, web designing tips, learn web designing

Change Image on mouse event

Small and simple Javascript Codes to change/alter image from older to new one then again change to earlier image when roll out from image. In the image roll-over/alter_image script of the previous session, the code for changing the image was placed inside the event handlers. This is fine if there are one [...]

Use of window.open method in javascript

To open a popup window we use window.open method in javascript:
Syntax:
window.open(url,”windowname”,[windowfeatures]);
URL: Denotes,URL of the page to open in the new window.
windowname: Denotes name of the popup window. The name can be used to refer this window again.
windowfeatures: These contains strings seperated by commas which refers the windows features in off and on mode OR 0 [...]

Contents: Javascript for Beginners

What you can do with JavaScript ?
Lesson -1. Embedding JavaScript in HTML
Lesson -2. Write text with javascript
Lesson -3. Variables in javascript
Lesson -4. Operators in javascript
Lesson -5. Conditional Statements
Lesson -6. JavaScript Comment
Popup Boxes
Lesson -7. JavaScript if else
Lesson -8. The JavaScript Switch Statement
Lesson -9. JavaScript Functions
Lesson -10. JavaScript For Loop
Lesson [...]

JavaScript Guidelines

JavaScript is Case Sensitive
Some other important things to know when scripting with JavaScript.
A function named “myfunction” is not the same as “myFunction” and a variable named “myVar” is not the same as “myvar”.
JavaScript is case sensitive - therefore watch your capitalization closely when you create or call variables, objects and functions.

White Space
JavaScript ignores extra [...]

Lesoon 18. JavaScript Special Characters

Insert Special Characters
In JavaScript you can add special characters to a text string by using the backslash sign.
The backslash (\) is used to insert apostrophes, new lines, quotes, and other special characters into a text string.
Look at the following JavaScript code:

var txt=”We are the so-called “Vikings” from the north.”;
document.write(txt);

In JavaScript, a string [...]

Lesson 17. JavaScript The onerror Event

The onerror Event
Using the onerror event is the old standard solution to catch errors in a web page.
We have just explained how to use the try…catch statement to catch errors in a web page. Now we are going to explain how to use the onerror event for the same purpose.
The onerror event is [...]

Lesoon 16. JavaScript Throw Statement

The Throw Statement
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 messages.
Syntax

throw(exception)

The exception can be a string, integer, Boolean or an object.
Note that throw is written in lowercase letters. Using uppercase letters will [...]

Lesson 15. JavaScript Try…Catch Statement

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 developers but not for users. When users see errors, they often leave [...]

Lesson 14. JavaScript Events

Events are actions that can be detected by JavaScript.

Events
By using JavaScript, we have the ability to create dynamic web pages. Events are actions that can be detected by JavaScript.
Every element on a web page has certain events which can trigger JavaScript functions. For example, we can use the onClick event of a button element [...]

Lesson 13. 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.
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 code in the body of the for … in loop [...]

Lesson 12. JavaScript Break and Continue

JavaScript break and continue Statements
There are two special statements that can be used inside loops: break and continue.
Break
The break command will break the loop and continue executing the code that follows after the loop (if any).
Example

<html>
<body>
<script type=”text/javascript”>
var i=0;
for (i=0;i<=10;i++)
{
if (i==3)
{
break;
}
document.write(”The number is ” + i);
document.write(”<br />”);
}
</script>
</body>
</html>

Result

The number is 0
The number is 1
The number [...]

Lesson 11. JavaScript While Loop

The while loop
The while loop is used when you want the loop to execute and continue executing while the specified condition is true.

while (var<=endvalue)
{
code to be executed
}

Note: The <= could be any comparing statement.
Example
Explanation: The example below defines a loop that starts with i=0. The loop will continue [...]

Lesson 10. JavaScript For Loop

Loops in JavaScript are used to execute the same block of code a specified number of times or while a specified condition is true.
Examples:
<html>
<body>
<script type=”text/javascript”>
for (i = 0; i <= 5; i++)
{
document.write(”The number is ” + i);
document.write(”<br />”);
}
</script>
<p>Explanation:</p>
<p>This for loop starts with i=0.</p>
<p>As long as <b>i</b> is less than, or equal to 5, the loop [...]

Lesson 9. JavaScript Functions

JavaScript Functions
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 that function.
You may call a function from anywhere within the page (or even from other pages if [...]

Lesson 8 . The JavaScript Switch Statement

Conditional statements in JavaScript are used to perform different actions based on different conditions.

Examples
Switch statement
<html>
<body>
<script type=”text/javascript”>
var d = new Date();
theDay=d.getDay();
switch (theDay)
{
case 5:
document.write(”<b>Finally Friday</b>”);
break;
case 6:
document.write(”<b>Super Saturday</b>”);
break;
case 0:
document.write(”<b>Sleepy Sunday</b>”);
break;
default:
document.write(”<b>I’m really looking forward to this weekend!</b>”);
}
</script>
<p>This JavaScript will generate a different greeting based on what day it is. Note that Sunday=0, Monday=1, Tuesday=2, etc.</p>
</body>
</html>
Result:
I’m really looking forward to [...]

Lesson 7. JS if else

if else in javascript :-

Syntax:
if(condition)
{
//code for execution;
}
else
{
//code for execution;
}
if condition is true then code written in his body execute, otherwise else’s code execute.
Example:
<HTML>
<HEAD>
<SCRIPT LANGUAGE=”JavaScript”>
<!–
<>function password() {
<>pass = prompt(’Type the word education’,””);
<>if(pass==”education”) {
location = ‘lession 2.html’;
}
else
{
alert(”Please try again”);
}
}
// –>
</SCRIPT>
</HEAD>
<BODY>
<A href=”javascript:password()”>
<IMG src=”pict.gif” NAME=”pic1″ ALT=”about us!” BORDER=”0″ align=”left”> </A>
<H3>Click the image to enter a password protected document. [...]