H I O X INDIA
Javascript Tutorial
Google
Web hscripts.com
 HOME  ||  Scripts  ||  Purchase  ||  Tutorials  ||  Images  ||  Tools  ||  Directories 
  :-)  Send Page   :-)   Feedback   :-)   Register   :-)   Links   :-)   Support   :-)   Bookmarks :-)  
 Forums   Hosting   Internet Stats   Easy Calculation   FUN Games 

Java-Script Tutorial
Introduction
Variables
Operators
Statements
Loops
Functions
Objects
Arrays
Browser Objects
Form DOM
Ask Your Doubts
Feedback





With Statement Code


Topic

How to use with statement in javascript?
Using many functions of an object in easiest way?



Explanation

with Statement:
        "with" statement is used when numerous function of an object is used or a function of an object is to be used numerous times.

Syntax:
with(object)
{
     // Calling the functions or methods of the object
}


For this example we will use the object "document" and its methods (functions) "write" and attribute "title".
Example Code:
<script language="javascript">
with(document)
{
write(" inside with statement <br>");
write(" using with(object) we can call its functions directly <br>");
write (" TITLE -"+title);
}
</script>


Result:

In the above example you can clearly see that the write function is executed numerous times with out calling document.write() and also title (document.title) is called. You can use any objects with "with" statement. e.g: date, math, etc. You will know more about these objects in later part of the tutorial.


        Javascript (JS) is one of the most used languages in the world. Some times spelled as Java Script. Hope you enjoy this tutorial. Do send your feedback or suggestions on this javascript or java script tutorial. This is a copyright content.

others

privacy policy     license     sitemap
© 2004-2005 HIOX INDIA - hioxindia.com

Other Links