Unit-III: Introduction to JavaScript: What is DHTML, JavaScript, basics,
variables, string manipulations,
mathematical functions, statements, operators, arrays, functions.
Q) What is DHTML? What are the features of DHTML?
DHTML stands for Dynamic HTML. DHTML is neither a language like HTML,
JavaScript etc. nor a web standard. It is just a combination of HTML,
JavaScript and CSS. It just uses these languages features to build dynamic web
pages. DHTML is a feature of Netscape Communicator 4.0, and Microsoft Internet
Explorer 4.0 and 5.0 and is entirely a "client-side" technology.
Features of DHTML:
1. Simplest feature is making the page dynamic.
2. Can be used to create animations, games, applications, provide new ways of navigating through web sites.
3. DHTML use low-bandwidth effect which enhance web page functionality.
4. Dynamic building of web pages is simple as no plug-in is required.
5. Facilitates the usage of events, methods and properties and code reuse
Features of DHTML:
1. Simplest feature is making the page dynamic.
2. Can be used to create animations, games, applications, provide new ways of navigating through web sites.
3. DHTML use low-bandwidth effect which enhance web page functionality.
4. Dynamic building of web pages is simple as no plug-in is required.
5. Facilitates the usage of events, methods and properties and code reuse
Q) Write a
brief note on JavaScript?
JavaScript
was developed by Netscape (company name) & initially called Livescript.
Later Microsoft developed and adds some futures Live script then it is called
“Jscript”. Jscript is nothing but Java script. We cannot create own classes in
java script.
Java script is designed to add
interactivity to HTML pages. It is usually embedded directly into html pages.
Java script is mainly useful to improve
designs of WebPages, validate from data at client side, detects (find)
visitor’s browsers, create and use to cookies, and much more.
Java script
is also called light weight programming language, because Java `script is
return with very simple syntax. Java script is containing executable code.
Java script is also called interpreted
language, because script code can be executed without preliminary compilation.
Creating
a java script:
- html script tag is used to
script code inside the html page.
<script> </script>
The script is containing 2
attributes. They are
1)
Language attribute: -
It represents name of scripting language such as JavaScript, VbScript.
<script
language=“JavaScript”>
2)
Type attribute: - It
indicates MIME (multi purpose internet mail extension) type of scripting code.
It sets to an alpha-numeric MIME type of code.
<script type=“text /
JavaScript”>
Location
of script or placing the script: -
Script code can be placed in both head & body section of html page.
Script
in head section Script in body
section
<html> <html>
<head> <head>
<script
type=“text / JavaScript”> <script
type= “text / JavaScript”>
Script code here </script>
</script> </head>
</head> <body>
<body> Script code here
</body> </body>
</html> </html>
Scripting
in both head & body section: -
we can create unlimited number of scripts inside the same page. So we can
locate multiple scripts in both head & body section of page.
Ex: -
<html>
<head>
<script type=“text /
JavaScript”>
Script code here
</script>
</head>
<body>
<script
type=“text / JavaScript”>
Script code here
</script>
</body>
</html>
Program: -
<html>
<head>
<script
language="JavaScript">
document.write("hai
my name is Mahaboob Shaik")
</script>
</head>
<body
text="red">
<marquee>
<script
language="JavaScript">
document.write("hai
my name is Sunil Kumar Reddy")
</script>
</marquee>
</body>
</html>
Q) Give a
brief note on Conditional statements in Javascript.
Conditional
statements:
-
In Java Script conditional statements are
useful to excuse different action for different decisions (conditions).
if
statement.
if-else
statement.
switch
statement.
if statement
is useful to perform(execute) a single statement or group of statements when
the condition is true.
if – else
statement is useful to execute a one block of code from two blocks where one
condition.
Switch
statement is very frequently to select one of many blocks of code for execution.
Ex: -
<HTML>
<BODY>
<script
language="JavaScript">
var d=new
Date( );
var
day=d.getDay( );
switch(day)
{
case 0:
document.write("enjoy
Sunday");
break;
case 1:
document.write("learning
Monday");
break;
case 2:
document.write("popper
Tuesday");
break;
case 3:
document.write("middle
Wednesday");
break;
case 4:
document.write("temple
Thursday");
break;
case 5:
document.write("finally
Friday");
break;
case 5:
document.write("super
Saturday");
break;
default :
document.write("I
am looking forward for this week end");
}
</script>
</BODY>
</HTML>