Call javascript in body tag on different events

Javascript can be called inside body tag of a web page. Mainly Javascript functions are called on events like Loading a web page, Clicking o...

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();">

COMMENTS

BLOGGER: 1
Loading...
Name

About,8,Adsense,3,Ant,1,Apache,2,Axis,3,Database,2,Earn Online,3,Eclipse,8,Firefox,9,Google,27,GWT,8,Hardware,3,IE,1,Internet,1,Java,48,Javascript,8,Jenkins,1,Linux,6,Miscellaneous,18,News,46,Opinion,9,PHP,1,Productivity,3,Puzzle,3,Security,3,Software,25,Sports,9,Spring,2,TDD,4,Tech,87,Tips,18,Tomcat,5,Tools,19,Tutorial,13,Ubuntu,4,Web application,12,Web Design,2,Web services,4,Windows,3,
ltr
item
digizolm12: Call javascript in body tag on different events
Call javascript in body tag on different events
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-t3RsUlu50bucjgModRaiIvfHfsaexwCWw__GnYz28yibb2ZZuI97RkCdRKeOoXcim9713TWDXE78hwsHoIKAek-AySJb5l0t_-nfnbPKEZX6TBr0rplJgrQ5ibXiU03oYiktqukxEHZQ/s400/call+javascript+in+body+tag.jpg
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-t3RsUlu50bucjgModRaiIvfHfsaexwCWw__GnYz28yibb2ZZuI97RkCdRKeOoXcim9713TWDXE78hwsHoIKAek-AySJb5l0t_-nfnbPKEZX6TBr0rplJgrQ5ibXiU03oYiktqukxEHZQ/s72-c/call+javascript+in+body+tag.jpg
digizolm12
https://digizolm12.blogspot.com/2007/09/call-javascript-in-body-tag-on.html
https://digizolm12.blogspot.com/
http://digizolm12.blogspot.com/
http://digizolm12.blogspot.com/2007/09/call-javascript-in-body-tag-on.html
true
1218430210337039745
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy