0% found this document useful (0 votes)
2 views4 pages

Web 5 69

The document provides JavaScript code examples demonstrating various objects such as strings, regular expressions, and window objects. It includes input and output sections for regular expression and string demonstrations, showcasing functionalities like searching, replacing, and string length. Additionally, it illustrates the use of window objects through a confirmation dialog for record deletion.

Uploaded by

alankar.stx
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

Web 5 69

The document provides JavaScript code examples demonstrating various objects such as strings, regular expressions, and window objects. It includes input and output sections for regular expression and string demonstrations, showcasing functionalities like searching, replacing, and string length. Additionally, it illustrates the use of window objects through a confirmation dialog for record deletion.

Uploaded by

alankar.stx
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

PRACTICAL NO.

5
Aim: Write javascript code for
A] Demonstrating different javascript objects such as string,regexpath,date.
1] Regular expression demonstration.
INPUT:
<html>
<body>
<p>regular expression</p>
<button on click=”myfunction()”>try it</button>
<script>
Function myfunction(){
Varstr=”all these are not possible using html”
Varn=str.search(/possible/i);
Document.write(“<br>”+n+”<br>”);
Var res=str.replace(/possible/I,”possible”);
Document.write(“<br>”+res+”<br>”);
Varpatt=/e/;
Document.write(“<br>”+patt.test(str)+”<br>”);}
</script>
</body>
</html>
OUTPUT:
18

ROLL NO.:69
All these are not possible using html!
true

2] String demonstration.
INPUT:
<html>
<body>
<script>
Var str1=”hey diddle diddle,the cat and the fiddle,the cow jumped over the
moon,”
Var str2=”the little dog laughed to see such fun,and the dish ran away with
the spoon!”;
Document.write(str1+”<br>”+str2+”<br>”);
Var sln=str1.length
Document.write(“<br>”+”length if string is”+sln+”<br>”);
Var x=’it\’s alright’;
Var y=”we are the so-called\”vikings\”from the north.”
Document.write(“<br>”+x+”<br>”);
Document.write(“<br>”+y+”<br>”);
</script>
</body>
</html>
OUTPUT:
Hey diddle diddle,the cat and the fiddle,the cow jumped over the moon,

ROLL NO.:69
The little dog laughed to see such fun,and the dish ran away with the spoon!
Length if string is70
It’s alright
We are the so-called”vikings”from the north.

B] Demonstrating different javascript objects such as windows,Navigator,


history, location, document.
1] windows objects demonstration.
INPUT:
<html>
<body>
<input type=”button”value=”delete record”onclick=”del()”/>
<script type=”text/javascript”>
Function del(){
Varans=confirm(“are you sure?”);
If(ans==true){
Alert(“ok”);

}
Else{
Alert(“ok”);
}

ROLL NO.:69
Else{
Alert(“cancel”);
}
}
</script>
</body>
</html>

OUTPUT:

ROLL NO.:69

You might also like