0% found this document useful (0 votes)
10 views57 pages

Web Application Practical Guide for XII Science

Uploaded by

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

Web Application Practical Guide for XII Science

Uploaded by

guptaaditya.0807
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Page |1

Kamla Nehru Public School


Chak Hakim, Phagwara
WEB APPLICATION PRACTICAL
FILE
GRADE- XII SCIENCE
SESSION: 2023-2024

Submitted to: Submitted by:

Mr. Amandeep Singh Navleen Kaur


XII Science (Non Medical)
Page |2

Certificate
This to certify that Ms. Aditya Gupta, student
of Grade-XII Science (Non Medical) has
successfully completed Web Application
Practical file during the academic session
2023-2034.

Acknowledgement
Page |3

I would like to express my gratitude


towards Principal madam Ms. P.K Dhillon
for providing opportunity to complete the
practical.
I would like to thank my subject teacher
Mr. Amandeep Singh whose constant
guidance and supervision was really
helpful. I would also like to thank my
parents and friends for their constant
encouragement.
I am thankful to CBSE also for giving me
this opportunity to understand Web
Application better.
Page |4

Content
S. No. Content Page
No.
Windows Movie Maker
1. I. Introduction
II. Components of Movie Maker.
III. Steps to prepare a video.
Customizing and Embedding Multimedia
2. Components
[Link] to Multimedia
[Link] of Multimedia Components
[Link] a code to add audio in a webpage
[Link] a code to add a YouTube video in a webpage
[Link] a code to add a Vimeo video in a webpage
[Link] a code to add Facebook video in a webpage
[Link] a code to add Flash Files in a webpage

3.
JavaScript
I. Introduction to JavaScript
II. Standardization
III. Features of JavaScript
IV. Applications of JavaScript
V. The Script tag
VI. Saving and Running the code
VII. Components of JavaSCript
VIII. Functions
IX. Events
Programming using JavaScript
 Printing a line of text
 Program to show date and time
 Program to show confirm box
 Program to show alert box
 Program to show prompt box
 Program to call a function
 Program to show function with an argument
 Function that returns value
 Function with arguments that returns a value
Page |5

Windows Movie Maker


Page |6

Introduction to Movies Maker


The first release of Windows Movie Maker was included
with Windows ME in 2000, but it was not available in
Windows 2000, which was released months before
Windows ME. Version 1.1 was included in Windows XP
a year later, and included support for creating DV AVI
and WMV 8 files. Version 2.0 was released as a free
update in November 2002, and added a number of new
features. Version 2.1, a minor update, is included in
Windows XP Service Pack 2. Windows XP Media Center
Edition 2005 introduced a new version of Windows
Movie Maker, 2.5, with more transitions and support for
DVD burning.
Microsoft has made version 2.6 of Movie Maker
available for download, and it runs on both Windows
Vista and Windows 7. While advanced users are likely
using a more sophisticated video editing program,
there’s no denying that Movie Maker is an excellent,
full-featured option for the average home user.
Page |7

Components of Windows
Movie Maker
The panes
The three major panes of Windows movie maker
are as following:
 Task Pane: The Tasks pane lists the common
tasks that may be needed to perform while making
a movie, including importing files, editing, and
publishing your movie.

 Collections Pane: The Collections pane displays


our collection folders, which contain clips.

 Contents Pane: The Contents pane shows clips,


effects, or transitions that are working with while
creating our movie, depending on the view being
worked with.
Page |8

The Storyboard and Timeline


 Storyboard view: The storyboard is the
default view in Windows Movie Maker. We can
use the storyboard to look at the sequence or
ordering of the clips in your project and easily
rearrange them, if necessary. This view also
let us see any video effects or video
transitions that have been added. Audio clips
that have added to a project are not displayed
on the storyboard.

 Timeline View: The timeline view provides a


more detailed view of our movie project and
allows us to make finer edits. Using this
timeline view, we can:-
1) Trim video clips, adjust the duration of
transitions between clips, and view the audio
track.

2) Review or modify the timing of clips in your


project. Use the timeline buttons to switch to
storyboard view, zoom in or out on details of
your project, narrate the timeline, or adjust
the audio levels.
Page |9

The Preview Monitor


The preview monitor enables us to view individual clips
or an entire project. By using the preview monitor, we
can preview our project before publishing it as a movie.
We can use the buttons underneath the preview
monitor to play or pause a clip, or to advance or rewind
a clip frame-by-frame. The Split button allows us to split
a clip into two parts at the point displayed in the
preview monitor.
P a g e | 10

Steps to prepare a video


Split and Combine Clips
Steps to Split a Clip:

1) In the Contents pane or on the storyboard/timeline, click the


video or audio clip that need to be split.

2) Under the preview monitor, click the Play button.

3) When the clip reaches a point near the place you want to
split the clip, click Pause. 4) Under the preview monitor, use
the playback controls to find the point where we want to split
the clip.

5) Under the preview monitor, click the Split button.


P a g e | 11

To Combine Clips
1) In the Contents pane or on the storyboard, hold
down the CTRL key, and then click the contiguous clips
which need to be combined.
2) Click Clip, and then click Combine. The name and
property information of the first clip in the group is
used for the new clip and the time is adjusted
accordingly.
P a g e | 12

Steps to trim a video clip


1) While in the storyboard view, click View, and then
click Timeline.
2) On the timeline, click the clip that wished to be trim.
3) Use the playback controls under the preview
monitor to find the point where you want to trim the
clip.
4) Do the following:
 When the playback indicator is at the
point where we want the selected video or
audio clip to start playing back, click Clip,
and then click Trim Beginning.
 When the playback indicator is at the
point where we want the selected video
or audio clip to stop playing back, click
Clip, and then click Trim End.
P a g e | 13

To Undo a Trimmed Clip


1) While being in storyboard view, click View, and then
click Timeline.
2) Click the trimmed clip on the timeline, click Clip, and
then click Clear Trim Points.

Create Clips
Windows Movie Maker creates clips that are based on
the time stamps that the DV camera inserts when the
source video is originally recorded, as well as
significant frame changes in the video.
1) In the Contents pane, select the video clip for which
you want to create clips.
2) Click Tools, and then click Create Clips.
P a g e | 14

Adding Titles in Windows Movie


Maker
1) Click that location on the storyboard/timeline where
title or credit is to be inserted.
2) Click Tools, and then click Titles and Credits.
3) Click the link that corresponds to location where
title or credit is to be inserted..
4) In the Enter text for title box, type the text that you
want to appear as the title or credit. After you type
the text, the monitor displays the default animation and
format for the title or credit need to be inserted.
5) To change the title animation, click Change the title
animation, and select a title animation from the list.
6) To change the font and color for your title, click
Change the text font and color, and then choose the
font, font color, formatting, background color,
transparency, font size, and position of the title to your
liking.
7) Click Add Title.
P a g e | 15

Steps to Edit an Existing Title


1) On the storyboard/timeline, click the title need to be
edited.
2) Click Edit, and then click Edit Title. 3) Make the
changes, and then click Add Title.

Steps to Remove a Title


1) On the storyboard/timeline, click the title that need
to be removed.
2) Click Edit, and then click Remove.

Steps to Remove a Title


1) On the storyboard/timeline, click the title that need
to be removed.
2) Click Edit, and then click Remove.
P a g e | 16

Publishing
Steps to Publish a Movie to your Computer
1) Click File, click Publish Movie.
2) Click This computer, and then click Next.
3) In the File name box, type a name for your movie.
4) In the Publish to box, choose where ever want to
save the movie once it's published, and then click Next.
5) Choose the settings to be used to publish the movie,
and then click Publish.
6) To watch the movie after it has been published,
select the Play movie after clicking Finish check box.
7) Click Finish.
P a g e | 17

Steps to Publish and Burn a Movie to a


Recordable CD
1) Insert a blank recordable CD or a rewriteable CD
into your CD burner.
2) Click File, and then click Publish Movie.
3) Click Recordable CD, and then click Next.
4) In the File name box, type a name for your movie.
5) In the CD Name box, type a name for the CD, and
then click Next.
6) Choose the settings to be used to publish the movie,
and then click Publish.
7) To publish and burn the movie to another
recordable CD, select the Publish this movie to another
recordable CDcheck box, and then click Next. Replace
the recordable CD with another recordable CD, and
then repeat steps 4 through 6.
P a g e | 18

Customizing and
Embedding Multimedia
Components
P a g e | 19

Introduction to Multimedia
Multimedia is a form of communication that uses a
combination of different content forms such as writing,
audio, images, animations, or video into a single
interactive presentation. It lets the user navigate,
interact, and create; and multimedia is used to
represent information in an interesting and interactive
manner.
Multimedia has become an inevitable part of any
presentation. It has found a variety of applications right
from entertainment to education. The evolution of
internet has also increased the demand for multimedia
content.
P a g e | 20

Types of Multimedia
Multimedia comes in several different formats. It can be
almost anything you see on internet. For instance- text,
audio, images, videos etc.
The most common way to discover the type of a file, is
to look at the file extension. When a browser sees the
file extension .htm or .html, it will treat the file as an
HTML file. The .xml extension indicates an XML file, and
the .css extension indicates a style sheet file. Pictures
are recognized by extensions like .gif, .png and .jpg.
Multimedia files also have their own formats with
different extensions like:

 .swf
 .wav
 .mp3
 .wmf
 .mp4
 .au
P a g e | 21

Examples of Multimedia
 Images
An image is a visual representation of something
through photographs or pictures. Extensions
are .jpg, .png etc.

 Audios
An audio is a sound, especially when recorded,
transmitted, or [Link] are .aiff, .mp3

 Videos
P a g e | 22

A video is a recording, reproducing, or


broadcasting of moving visual images.
P a g e | 23

Embedding an audio in
webpage
 In Internet Explorer (IE) the audio can be included
using <BGSOUND> tag. bgsound tag works only in
IE and not in any other browsers. Example Code:
<bgsoundsrc="[Link]" LOOP="-1" >

 The audio can be included using <embed> tag for


Netscape like browsers. Example Code: <EMBED
SRC="he-knows.mp3" HIDDEN="true"
AUTOSTART="true" LOOP="infinite" Height=145
width=160></EMBED>
P a g e | 24

Various Quick and Easy Ways


to Embed MP3 Files into the
Site
I. Using the Object Tag:
Example Code:
<object data="[Link]" type="audio/x-
mplayer2" width="320" height="240">
<param name="src" value="[Link]">
<param name="autoplay" value="false">
<param name="autoStart" value="0"> <param
name="bgcolor"value="#FFFFFF"> Hear the
sound :
<a href="[Link]">music</a> </object>

II. Google Reader MP3 Player


Example code:
<embed height="27px" width="400px"
pluginspage="[Link]
/getflashplayer"
flashvars="playerMode=embedded"
wmode="transparent" bgcolor="#ffffff"
quality="best" allowscriptaccess="never"
src=[Link]
[Link]?
audioUrl=MP3_FILE_URL
type="application/x-shockwave-flash"
classname="audio-player-embed"/>
P a g e | 25

III. Yahoo Media Player


Example code:
<script type="text/javascript"
src="[Link]
cript>

IV. MixPod
MixPod creates a free flash widget to embed into our
site. Setting up a MixPod is super easy and requires
no knowledge of coding beyond where to paste the
snippet of code they give us. All we do is paste in our
MP3 link, insert the artist/track info for all the songs
in your playlist, and choose your skin and colors.
Then MixPod provides you with a rather large chuck
of code to paste into the site.

V. Using a Plug-in
Plug-ins are programs that helps browser to perform at
a higher level. A sound plugin does basically the same
thing the helper application does, except it works inside
the Netscape Navigator window rather than starting up
as a whole other program. Instead of WHAM popping up
and Netscape being pushed to the back while the
sound runs, a sound plug-in works inside of Netscape.
P a g e | 26

VI. MIDI
It's an acronym that stands for Musical
Instrument Digital Interface. That's a program
that acts as a go-between for an instrument and
something that creates the sound. Sort of like
running a guitar through a computer and then
out a speaker. A midi file over the Web works as
a program that runs the sound card.
P a g e | 27

Code to embed a YouTube


video in Webpage
If anyone run a branded channel on YouTube, there’s a
good opportunity to use YouTube embedding facilities.
Once submitted, our video gets involved into the full
cycle of YouTube life with its views, search queries,
comments, ratings, playlists, etc. We upload a video to
our channel, go to the player, acquire the embed code
and paste it into our web page. YouTube also provides
additional options to customize the player like play in
HD, switch to HTTPS, suggest other videos, etc.
Example code:
<iframe width="560" height="315"
src="[Link]
si=MmMoxCG-wo5mGtFb" title="YouTube video
player" frameborder="0" allow="accelerometer;
autoplay; clipboard-write; encrypted-media;
gyroscope; picture-in-picture; web-share"
allowfullscreen></iframe>
P a g e | 28

Write a code to add Vimeo


Video
Vimeo videos are also viewed by thousands of web
users and can be easily integrated into other websites
or blogs. Vimeo player is very handsome and
streamlined.
Example code: <iframe
src="[Link]
h=e40f870dbf&color=ff214f&byline=0&portrait=0"
width="640" height="268" frameborder="0"
allow="autoplay; fullscreen; picture-in-
picture" allowfullscreen></iframe>
<p><a href="[Link]
BELLE NUIT D&#039;&Eacute;T&Eacute;</a> from <a
href="[Link]
">&Eacute;cole des Nouvelles Images</a> on <a
href="[Link]
P a g e | 29

Code to embed A Facebook


Video in Webpage
Facebook doesn't officially provide any video
embedding options, still if a video is available
only on Facebook, there is a workaround. Each
video on Facebook has an id which shows in
the URL.
Example code: <objectwidth="400"height="224">
<paramname="allowfullscreen"value="true/>
<paramname="allowscriptaccess"value="always"/
>
<paramname="movie"value="[Link]
com/v/xxx"/>
<embedsrc="[Link]
="application/x-shockwave-flash"
P a g e | 30

allowscriptaccess="always"allowfullscreen="tr
ue"width="400"height="224"> </embed>
</object>
P a g e | 31

A code to add flash files into


webpage
There are times, particularly when using a content
management system, where we will have to insert
some Flash media into a web page by typing out the
code manually. To insert Flash onto a web page or
content management system manually, we must first
upload the SWF file to a web server using a protocol
called FTP or through an upload form on the content
management system.
Example code:
<object width="550" height="400">
<param name="movie" value="[Link]">
<embed src="[Link]" width="550"
height="400"> </embed>
</object>
P a g e | 32

JavaScript
P a g e | 33

Introduction to
JavaScript
JavaScript is a scripting language that enables you to create
dynamically updating content, control multimedia, animate
images, pop-up menus etc. It is a lightweight object-oriented
programming language used by developers to make web pages
interactive.

Nowadays, JavaScript has become very useful in both game


development and the creation of desktop applications.
JavaScript was developed in 1995 by Brendan Eich, at
Netscape, and first released with Netscape 2 early in 1996. It
was initially called as LiveScript, but was renamed as JavaScript
in order to capitalize the popularity of Sun Microsystem's Java
language.

JavaScript's use in applications outside of web pages also like


in PDF documents, site-specific browsers, and desktop widgets
and other useful applications. JavaScript was formalized in the
ECMAScript language standard and is primarily used as part of
a web browser (client-side JavaScript). This enables
programmatic access to computational objects within a host
environment.

JavaScript very quickly gained widespread success as a client-


side scripting language for web pages. Microsoft introduced
JavaScript support in its own web browser, Internet Explorer, in
version 3.0, released in August 1996.
P a g e | 34

Standardization
In November 1996, Netscape announced that it had
submitted JavaScript to European Computer
Manufacturers Association (ECMA) for consideration as
an industry standard, and subsequent work resulted in
the standardized version named ECMAScript. ECMA is
an international standard organization for information
and communication system.
In June 1997, ECMA International published the first
edition of the ECMA-262 specification. A year later, in
June 1998, some modifications were made to adapt it
to the ISO/IEC-16262 standard, and the second edition
was released. The third edition of ECMA-262 is the
version most browsers currently use.
Fourth edition of ECMAScript standard was not released
and does not exist. Fifth edition of the ECMAScript
standard was released in December 2009. The current
edition of ECMAScript standard is 5.1 and it was
released in June 2011. This way, JavaScript has become
one of the most popular programming languages on the
web.
P a g e | 35

Features of Javascript
Browser Support
All browsers have accepted JavaScript as a scripting
language and provide integrated support for it. For
example, to access flash content, you need to install
flash plug-in in your browser. But to use JavaScript, you
don't have to use any plug-in at all.

JavaScript can be used on Client Side


as well as on Server Side
JavaScript has access to Document Object Model DOM
of browser. You can change the structure of web pages
at runtime. Thus, JavaScript can be used to add
different effects to Web Pages. On the other hand,
JavaScript could be used on the server side as well.

Functional Programming Language


In JavaScript, function could be assigned to variables
just like any other data types. A function can accept
another function as a parameter and can also return a
function. You can have functions with no name as well.
This provides you the ability to code in functional
programming style.
P a g e | 36

Support for Objects


JavaScript is an object oriented language. However, the
way JavaScript handles objects and inheritance is bit
different from conventional object oriented
programming languages like C++/ Java. JavaScript
supports most of the object oriented concepts while
being simple to learn and use.

Run-time Environment
JavaScript typically relies on a run-time environment
(e.g. in a web browser) to provide objects and methods
by which scripts can interact with "the outside world".
In fact, it relies on the environment to provide the
ability to include/import scripts (e.g. HTML <script>
elements). This is not a language feature as such but it
is common in most JavaScript implementations.

Vendor-specific Extensions
JavaScript is officially managed by Mozilla Foundation,
and new language features are added periodically.
However, only some JavaScript engines support these
new features.
P a g e | 37

Object Type
JavaScript supports the development of object types
and in this context JavaScript supports both predefined
and user-defined objects. It is possible to assign objects
of any type to any variable. It is possible to instantiate
the defined object types to create object instances in
JavaScript, which is a very powerful feature of Object
based language.

Object Instantiation
In order to carry out the process of creating specific object
instances available in JavaScript, you can make use of a
new operator. These two powerful, object-based features
supported by JavaScript described above make this an
object model language. In JavaScript, the object types are
defined by properties and methods. Properties of Objects
are used to access the data values contained in an object.
You can make use of the properties of JavaScript objects for
editing as well as reading depending on the object’s
nature. That is, if you want to carry out functions on the
object, this is achieved by using methods that make use of
the object’s properties. These are some of the features
that give JavaScript an ability to handle simple as well as
complex tasks. This way, JavaScript has remained as the
most popular programming language for a long time. It is
also a good language for web designers who want to learn
computer programming as it supports object oriented as
well as function concepts and to use it, you just need a
browser and a text editor.
P a g e | 38

Applications of
JavaScript
Developing Multimedia Applications
The users can use JavaScript to add multimedia
elements. With JavaScript you can show, hide, change,
resize images and create images rollovers. You can
create scrolling text across the status bar, thus making
multimedia applications more interactive.

Create Pages Dynamically


Based on the user’s choice, the date or other external
data, JavaScript can produce pages that are customized
to the user.

Interact with the User


JavaScript can do some processing of forms and can
validate user input when the user submits the form.

JavaScript Objects are Similar to


Dictionaries
In JavaScript, objects are just collections of name-value
pairs. JavaScript objects are considered as a dictionary
with string keys. The users can get and set the
properties of an object using either the familiar "." (dot)
operator, or the "[ ]" operator, which is typically used
when dealing with a dictionary.
P a g e | 39

The Script Tag

The <SCRIPT> tag alerts a browser that


JavaScript code follows. It is typically
embedded in the HTML.

<SCRIPT language = "JavaScript">


statements
</SCRIPT>
P a g e | 40

Saving and running a


program in JavaScript

1. Open any editor like notepad write


the program.
2. Save the program in a desired file with
‘.html’ extension a proper file.
3. Go to the file that you created and saved,
right click on it and open it with a browser
of your choice.
P a g e | 41

Components of
JavaScript
OPERATORS
JavaScript operators can be used to perform several
operators such as:
 Arithmetic Operators
 Comparison Operators
 Logical Operators
 Relational Operators
 Assignment Operators
 Conditional Operators

String
A string consists of sequence of one or more characters
that may consist of letters or numbers.

DATATYPES
A data type is a classification of the type of data that a
variable or object can hold. Data type is an important
factor in virtually all computer programming languages,
including visual basic, C#, C/C++ and JavaScript. When
programmers create computer applications, both
desktop and web-based, data types must be referenced
P a g e | 42

and used correctly to ensure the result of the


application's functions is correct and error-free.

OBJECTS
JavaScript object is a non-primitive data-type that
allows you to store multiple collections of data. They
are simply collections of name-value pairs. The ‘name’
part is a JavaScript string, while the value can be any
JavaScript value including more objects. Here an object
name is defined.
// object creation
const person = {
name: 'John',
age: 20
};
[Link](type of person);

ARRAYS
JavaScript Array is a single variable that is used to store
elements of different data types. They work somewhat
similar as objects but they have a property called
‘length’. The length (size) of the array is always one
more than the highest index in the array. One of some
ways of creating arrays is as follows:
const chocolates = [];
chocolates[0]= "Dairy Milk";
chocolates [1]= "Kit-Kat";
chocolates [2]= "Snickers";
P a g e | 43

METHODS
Arrays and strings come with a number of
methods. Some are listed below-
1. [Link]() in JavaScript is used to print any kind
of variables defined before in it .

2. [Link]()method logs the number of times


that this particular call to count() has been called.
3. push() adds one or more items.
4. alert()method displays an alert box with a message
and an OK button.
5. shift() removes the first element of an array and
return that element.
6. remove() removes an element (or node) from the
document.
7. prompt()is used to display a dialog box with an
optional message prompting the user to input some
text.
8. substring()method extracts characters, between two
indices (positions), from a string, and returns the
substring.
9. pop() removes and returns the last item.
10. join() joins all elements of an array into a
string.
P a g e | 44

FUNCTIONS
Functions are a set of statements that performs a task
or calculates a value.
For Instance:
let x = myFunction(2, 3);
[Link]("demo").innerHTML = x;

function myFunction(a, b) {
return a + b;
P a g e | 45

EVENTS
The objects in web pages are organised in a
hierarchical structure. All objects have properties and
methods. In addition, some objects also have ‘events’.
Events are usually user actions that are associated with
an object. The ‘event handler’ is a command that is
used to specify actions in response to an event. Some
of the most commonly used vents are listed below:
 onLoad - occurs when a page loads in a browser.
 onUnload - occurs just before the user exits a
page.
 onMouseOver - occurs when you point to an
object.
 onMouseOut - occurs when you point away from
an object.
 onSubmit - occurs when you submit a form.
 onClick - occurs when an object is clicked.
P a g e | 46

Programming using
JavaScript
P a g e | 47

1) Printing a line of text in a webpage using


JavaScript.
<html>

<head>

<script>

function myFunction()

{ return("Have a nice day!!!"); } </script>

</head>

<body>

<script>

[Link](myFunction());

</script>

</body>

</html>
P a g e | 48

2) Program to show date and time


<html>
<body>
<script>
var d=new Date();
[Link](d);
</script>
</body>
</html>
P a g e | 49

3)Program to show the confirm box


<html>

<head>

<p>Click the button to display a confirm box.</p>

<button onclick="myFunction()">try it

</button>

<p id="demo">

</p>

<script>

function myFunction()

var x; var r=confirm("press a button"); if(r==true)

x="you pressed OK";

else

x="you pressed cancel";

[Link]("demo").innerHTML=x;

} </script>

</body>

</html>
P a g e | 50
P a g e | 51

4)Program to show the alert box


<html>
<head>
<script>
function myFunction()
{
alert("HELLO!");
}
</script>
</head>
<body>
<input type="button"onclick="myFunction()
"value="show me the alert box"/>
</body>
</html>
P a g e | 52

4)Program to show the prompt box


<html>
<body>
<p><strong>Click the button to demonstrate the
prompt box.</strong></p> <button
onclick="myFunction()">try it</button> <p
id="demo"></p>
<script>
function myFunction()
{
var x; var person;
person=prompt("please enter your name"," ");
if(person!=null)
{
x=("hello" +person+ "!how are u today?");
}
[Link]("demo").innerHTML=x;
}
</script>
</body>
</html>
P a g e | 53
P a g e | 54

5) Program to call a function


<html>
<head>
<script>
function myFunction()
{
confirm("Welcome!!!");
}
</script>
</head>
<body>
<button onclick="myFunction()">Click Here</button>
<p><strong>A function will be called when the button
is clicked. </strong></p>
</body>
</html>
P a g e | 55

6) Program to show function with an


argument
<html>
<body>
<p>click the button to call a function with
arguments</p>
<button onclick="myFunction('Have a ', 'day')">try
it</button> <script> function myFunction(name,object)
{
alert(name+ "great " + object);
}
</script>
</body>
</html>
P a g e | 56

7) Function that returns a value


<html>
<head>
<script>
function myFunction()
{
return("Be the change you want to see in the
world!");
}
</script>
</head>
<body>
<script>
[Link](myFunction());
</script>
</body>
</html>
P a g e | 57

Function with arguments that returns a value


<html>
<body>
<p>Function with arguments that returns the
result</p>
<p id="demo"></p>
<script> function myFunction(x,y) {
return x+y;
}
[Link]("demo").innerHTML=myFunction(
2,10);
</script>
</body>
</html>

You might also like