Javascript can be called inside body tag of a web page. Mainly Javascript functions are called on events like Loading a web page, Clicking on a button, Moving mouse, Focusing on an element, etc. For each of these events, there are defined methods and they are fired at that particular event. For example; onclick() is triggered on a mouse click event while onmouseover() is called when mouse moves over an element. But you can call Javascript functions even without any event.
Available events for body tag can be listed as follows.
ONCLICK : mouse button clicked
ONDBLCLICK : mouse button double-clicked
ONMOUSEDOWN : mouse button is pressed
ONMOUSEOVER : mouse moved onto an element
ONMOUSEMOVE : mouse moved over an element
ONMOUSEOUT : mouse moved out of an element
ONMOUSEUP : mouse button is released
ONKEYPRESS : key pressed and released
ONKEYDOWN : key pressed
ONKEYUP : key released
There are two special events that are specific to body tag. Those are;
ONLOAD : document loaded completely
ONUNLOAD : document unloaded
Calling a Javascript method
At any of the above events, you can call any javascript function from your body tag. A Javascript function named testAlert() can be called as below.
<body onload="testAlert();">
To call move than one Javascript function, you have to write the function named separating by semi-colons ( ; ) as below.
<body onclick="validate(); calculate(); submit();">
Post Top Ad
Responsive Ads Here
Thursday, September 13, 2007
Call javascript in body tag on different events
Tags
# Javascript
# Tech
About Kamal
Tech
Labels:
Javascript,
Tech
Subscribe to:
Post Comments (Atom)
Post Top Ad
Responsive Ads Here
Author Details
Templatesyard is a blogger resources site is a provider of high quality blogger template with premium looking layout and robust design. The main mission of templatesyard is to provide the best quality blogger templates which are professionally designed and perfectlly seo optimized to deliver best result for your blog.
No comments:
Post a Comment