Web Programming: 1. Demonstrate The Collections All With An Example?
Web Programming: 1. Demonstrate The Collections All With An Example?
<html>
<head>
<title>object model (using all collections)</title>
<script type="text/javascript">
var elements="";
function start()
{
for(var i=0;i<document.all.length;++i)
elements+="<br>"+document.all[i].tagName;
pText.innerHTML+=elements;
alert(elements);
}
</script>
</head>
<body onload="start()">
<h2>welcome to MJCET</h2>
<p id="pText">Branch name on this page :</p>
<!-- CSE,ECE,MCA,MBA,EEE-->
<!-- Address :Banjara Hills ,Road no :3-->
</body>
</html>
Output:
<HTML>
<HEAD><TITLE>Object Model(Using collection children)</TITLE>
<SCRIPT TYPE="text/javascript">
var elements= "<UL>";
function start(object)
{
var i=0;
elements+="<LI>"+object.tagName+"<UL>";
for(i=0;i<object.children.length;i++)
{
if(object.children[i].children.length)
start(object.children[i]);
else
elements+="<LI>"+object.children[i].tagName+"</LI>";
}
elements+="</UL>"+"</LI>";
}
</SCRIPT>
</HEAD>
<BODY ONLOAD="start(document.all[0]);
myp.outerHTML+=elements;
myp.outerHTML+='</UL>';">
<!--this program will display all elements in page-->
<!--List will be an unordered list-->
<H2>Welcome to our <STRONG>WEB PAGE</STRONG></H2>
<P id="myp">Elements on this Web Page:</P>
</BODY>
</HTML>
OUTPUT:
FILENAME:2a.html
<html>
<head>
<title>Demonstrate the children frames</title>
<script type="text/javascript">
</script>
</head>
<frameset rows="100,*,*">
<frame src="2b.html" name="upper">
<frame src="" name="middle">
<frameset cols="50%,*">
<frame src="" name="lowerL">
<frame src="" name="lowerR">
</frameset>
</frameset>
</html>
FILENAME:2b.html
<html>
<head>
<title>frames collections</title>
<script type="text/javascript">
function start()
{
var text=prompt("what is your name?","");
parent.frames("lowerL").document.write("<h1>hello,"+text+"</h1>");
parent.frames("lowerR").document.write("<h1>welcome to MJCET"+"</h1>");
parent.frames("middle").document.write("<h1>your name is "+text+"</h1>");
}
</script>
</head>
<body onload="start()">
<h1>cross-frame scripting</h1>
<h1>user details with images</h1>
</body>
</html>
//main
<HTML>
<HEAD><TITLE>Navigator Object</TITLE>
<SCRIPT TYPE="text/javascript">
function start()
{
if(navigator.appName=="Microsoft Internet Explorer")
{
if(navigator.appVersion.substring(1,0)>="4")
document.location="Q3newIEversion.html";
else
document.location="Q3oldIEversion.html";
}
else
document.location="Q3NSversion.html";
}
</SCRIPT>
</HEAD>
<BODY ONLOAD="start()">
<P>Displays the information about the web browser</P>
</BODY>
</HTML>
//NSversion
<HTML>
<HEAD>
<TITLE>Netscape Version</TITLE>
</HEAD>
<BODY>
<H1><BR><BR><BR><BR>
<CENTER>
You are currently using netscape navigator<BR>
newer Version!
</CENTER>
</H1>
</BODY>
</HTML>
//newIEversion
<HTML>
<HEAD>
<TITLE>Internet Explorer Version</TITLE>
</HEAD>
<BODY>
<H1><BR><BR><BR><BR>
<CENTER>
You are currently using Internet Explorer<BR>
newer Version!
</CENTER>
</H1>
//oldIEversion
<HTML>
<HEAD>
<TITLE>Internet Explorer Version</TITLE>
</HEAD>
<BODY>
<H1><BR><BR><BR><BR>
<CENTER>
You are currently using Internet Explorer<BR>
older Version!
</CENTER>
</H1>
</BODY>
</HTML
OUTPUT:
<HTML>
<HEAD><TITLE>Demonstrating ONCLICK & ONLOAD</TITLE>
<SCRIPT TYPE="text/javascript" >
alert("Hii......!");
var sec=0;
function start()
{
window.setInterval("updateTime()",1000);
}
function updateTime()
{
sec++;
soFar.innerText=sec;
}
</SCRIPT>
</HEAD>
<BODY ONLOAD="start()">
<P><H1>Seconds u have spent viewing this page so far :
<STRONG id="soFar">0</STRONG></H1></P>
<P><H1>Click on below button to demonstrate onclick event.</H1></P>
<INPUT TYPE="button" VALUE="Click Me!" ONCLICK="alert('Hi Again!')">
</BODY>
</HTML>
OUTPUT:
ONCLICK="doThis()">
</BODY>
</HTML>
OUTPUT:
OUTPUT:
<HTML>
<HEAD>
<TITLE>Event Model-ONMOUSEOVER,ONMOUSEOUT</TITLE>
<SCRIPT LANGUAGE="javascript">
image1=new Image();
image1.src=" al.jpg";
image2=new Image();
image2.src="Cute.jpg";
function mover()
{
if(event.srcElement.id=="image")
{
event.srcElement.src="image2.src";
return;
}
}
function mout()
{
if(event.srcElement.id=="image")
{
event.srcElement.src="image1.src";
return;
}
}
document.onmouseover=mover;
document.onmouseout=mout;
</SCRIPT>
</HEAD>
<BODY STYLE="background-color:wheat">
<H3>Observe this web page ,whenever the mouse is on the image it is
displaying one image & when the mouse cursor is moving out of the image another image is
displayed.
<P>This is the effect of Event Models OMMOUSEOVER & ONMOUSEOUT.<BR>
</H3>
<IMG SRC="al.jpg" id="image" HEIGHT="300" WIDTH="300">
</BODY>
</HTML>
<HTML>
<HEAD><TITLE>Event Model - ONFOCUS & ONBLUR</TITLE>
<SCRIPT TYPE="text/javascript">
var helpArray=["Enter your name in this input box.","
This box text is explaining about what to enter in the boxes provided","Enter
some text",""];
function helpText(num)
{
myForm.helpBox.value=helpArray[num];
}
</SCRIPT>
</HEAD>
<BODY>
<FORM ID="myForm">
Name:<INPUT TYPE="text" NAME="name" ONFOCUS="helpText(0)"
ONBLUR="helpText(3)"><BR>
Text:<TEXTAREA NAME="comments" ROWS="5" COLS="20"
ONFOCUS="helpText(2)" ONBLUR="helpText(3)">
</TEXTAREA>
OUTPUT:
//flipfilters
<html>
<head>
<title>The flip filter</title>
<table>
<tr>
<!-- Filters are applied in style declarations -->
<tr>
<!-- More than one filter can be applied at once -->
<td style = "filter: flipv fliph">WELCOME</td>
<td style = "filter: flipv">WELCOME</td>
</tr>
</table>
</body>
</html>
OUTPUT:
OUTPUT:
</body>
</html>
OUTPUT:
ROLL NO:006-09-013 PAGE NO:16
WEB PROGRAMMING
function start()
{
window.setInterval( "runDemo()", 500 );
}
function runDemo()
{
shadowText.innerText =
"Shadow Direction: " + shadowDirection % 360;
shadowText.filters( "shadow" ).direction = ( shadowDirection % 360 );
shadowDirection += 45;
}
// -->
</script>
</head>
<h1 id = "shadowText" style = "position: absolute; top: 25; left: 25; padding: 10;
filter: shadow( direction = 0, color = red )">WELCOME .... shadow Direction:
0</h1>
</body>
</html>
<html>
<head>
<title>Implementation of Miscellaneous image filter</title>
<style type="text/css">
cap{font-weight:bold;background-color:green;text-align:center}
</style>
</head>
<body>
<table border=2>
<tr class="cap">
<td>Normal</td>
<td>Grayscale</td>
<td>Xray</td>
<td>Invert</td>
</tr>
<tr>
<td><img src="very-cute-baby-on-mobile.jpg "></td>
<td><img src="very-cute-baby-on-mobile.jpg "style="filter:gray"></td>
<td><img src="very-cute-baby-on-mobile.jpg"style="filter:xray"></td>
<td><img src="very-cute-baby-on-mobile.jpg "style="filter:invert"></td>
</tr>
</table>
</body>
</html>
OUTPUT:
function reBlur()
{
blurImage.filters( "blur" ).direction =
document.forms( "myForm" ).Direction.value;
blurImage.filters( "blur" ).strength =
document.forms( "myForm" ).Strength.value;
blurImage.filters( "blur" ).add =
document.forms( "myForm" ).AddBox.checked;
}
function startDemo()
{
timer = window.setInterval( "runDemo()", 5 );
}
function runDemo( )
{
document.forms( "myForm" ).Strength.value =
strengthIndex;
document.forms( "myForm" ).Direction.value =
( blurDirection % 360 );
if ( strengthIndex == 35 || strengthIndex == 0 )
upDown = !upDown;
if ( strengthIndex == 0 )
blurImage.filters( "blur" ).direction =
( ( blurDirection += 45 ) % 360 );
}
// -->
</script>
</head>
<body>
<form name = "myForm" action = "">
<tr>
ROLL NO:006-09-013 PAGE NO:20
<td>Direction:</td> WEB PROGRAMMING
<td><select name = "Direction">
<option value = "0">above</option>
<option value = "45">above-right</option>
<option value = "90">right</option>
<option value = "135">below-right</option>
<option value = "180">below</option>
<option value = "225">below-left</option>
<option value = "270">left</option>
<option value = "315">above-left</option>
</select></td>
</tr>
<tr>
<td>Strength:</td>
<td><input name = "Strength" size = "3" type = "text"
maxlength = "3" value = "0" /></td>
</tr>
<tr>
<td>Add original?</td>
<td><input type = "checkbox" name = "AddBox" /></td>
</tr>
<tr>
<td align = "center" colspan = "2">
<input type = "button" value = "Apply"
onclick = "reBlur();" /></td>
</tr>
<tr>
<td colspan = "2">
<input type = "button" value = "Start demo"
onclick = "startDemo();" />
<input type = "button" value = "Stop demo"
onclick = "window.clearInterval( timer );" /></td>
</tr>
</table>
</form>
</body>
</html>
OUTPUT:
<html>
<head>
<title>rEVEAL Transitions</title>
var counter = 0;
var whichImage = true;
function blend()
{
if ( whichImage ) {
image1.filters( "revealTrans" ).apply();
image1.style.visibility = "hidden";
image1.filters( "revealTrans" ).play();
}
else {
image2.filters( "revealTrans" ).apply();
image2.style.visibility = "hidden";
image2.filters( "revealTrans" ).play();
}
}
if ( fromImage ) {
image1.style.zIndex -= 2;
image1.style.visibility = "visible";
image2.filters("revealTrans").transition =
counter % 24;
}
else {
image1.style.zIndex += 2;
image2.style.visibility = "visible";
image1.filters("revealTrans").transition =
counter % 24;
}
whichImage = !whichImage;
blend();
transitionDisplay.innerHTML = "Transition " +
counter % 24 + ": " + transitionName[ counter % 24 ];
}
// -->
</script>
</head>
</body>
</html>
OUTPUT:
<object id = "Images"
classid = "CLSID:333C7BC4-460F-11D0-BC04-0080C7055A83">
<param name = "DataURL" value = "images.txt" />
<param name = "UseHeader" value = "True" />
</object>
case "first":
recordSet.MoveFirst();
break;
case "previous":
recordSet.MovePrevious();
if ( recordSet.BOF )
recordSet.MoveLast();
break;
case "next":
recordSet.MoveNext();
if ( recordSet.EOF )
recordSet.MoveFirst();
ROLL NO:006-09-013 PAGE NO:26
WEB PROGRAMMING
break;
case "last":
recordSet.MoveLast();
break;
}
}
// -->
</script>
</head>
<body>
</body>
</html>
OUTPUT:
<html >
<head>
<title>Data Binding and Tables</title>
<object id = "Colors"
classid =
"CLSID:333C7BC4-460F-11D0-BC04-0080C7055A83">
<param name = "DataURL" value =
"HTMLStandardColors.txt" />
<param name = "UseHeader" value = "TRUE" />
<param name = "TextQualifier" value = "@" />
<param name = "FieldDelim" value = "|" />
</object>
</head>
<thead>
<tr style = "background-color: mediumslateblue">
<th>Color Name</th>
<th>Color RGB Value</th>
</tr>
</thead>
<tbody>
<tr style = "background-color: lightsteelblue">
<td><span datafld = "ColorName"></span></td>
<td><span datafld = "ColorHexRGBValue"
style = "font-family: monospace"></span></td>
</tr>
</tbody>
</table>
</body>
</html>
<html >
<head>
<title>Structured Graphics - Shapes</title>
</head>
<body>
"CLSID:369303C2-D7AC-11d0-89D5-00A0C90833E6">
</object>
</html>
OUTPUT:
<html>
<body bgcolor="aliceblue">
<script type="text/vbscript">
document.write("<br />")
</script>
</body>
</html>
OUTPUT:
<head>
<title>Arrays</title>
<script language="vbscript">
Option Explicit
Dim j
next
document.write("<br>")
end sub
Dim fixedSize(3),fixedArray,dynamic(),k
ReDim dynamic(3)
fixedArray=Array("A","B","C")
fixedSize(k)=50-k
dynamic(k)=chr(75+k)
next
call DisplayArray(fixedSize,"fixedSize")
call DisplayArray(fixedArray,"fixedArray")
call DisplayArray(dynamic,"dynamic")
dynamic(3)=3.343
dynamic(4)=77.37443
</script>
</head>
</html>
OUTPUT:
Option Explicit
Dim k, suffix
If InStr( 1, "aeiou", _
suffix = "y"
Else
suffix = "ay"
End If
Next
End Function
Sub cmdButton_OnClick()
Dim phrase
TranslateToPigLatin( phrase )
End Sub
</script>
</head>
<body bgcolor="blueslate">
<p>Pig Latin
</p><p>
</form>
</body>
</html>
<html>
<head>
Option Explicit
Class Person
name = fn
End Property
FirstName = name
yearsOld = a
End Property
Age = yearsOld
End Property
If Validate( n ) Then
ssn = n
Else
ssn = "000-00-0000"
End If
End Property
SocialSecurityNumber = ssn
End Property
Dim regularExpression
regularExpression.Pattern = "^\d{3}-\d{2}-\d{4}$"
Validate = True
Else
Validate = False
End If
End Function
& ssn
End Function
End Class
Sub cmdButton_OnClick()
Dim p
With p
.FirstName = Document.Forms(0).txtBox1.Value
.SocialSecurityNumber =_
Document.Forms(0).txtBox3.Value
End With
End Sub
</script>
</head>
<body bgcolor="powderblue">
<p>Enter age
</p><p>
</form>
</html>
OUTPUT: