Your Ad Here


Go Back   VIPrapid.com > WEBMASTERS ZONE > Programming

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-05-2009, 08:27 PM
VIP
 

Join Date: Mar 2009
Location: Before Internet
Posts: 80
Arrow DHTML Event Handlers

HTML events can trigger actions in the browser, like starting a JavaScript when a user clicks on an element.

Examples

onclick
Turn on the light! How to change an image when the user clicks it.

onmousedown & onmouseup
This time the light is on only when the user holds down the mouse button.

onload
Displays an alert box when the page has finished loading.


Event handlers


An event handler allows you to execute code when an event occurs.

Events are generated by the browser when the user clicks an element, when the page loads, when a form is submitted, etc.
Example

A header changes when the user clicks it:
Code:
<h1 onclick="this.innerHTML='Ooops!'">Click on this text</h1>
You can also add a script in the head section of the page and then call the function from the event handler:

Code:
<html>
<head>
<script type="text/javascript">
function changetext(id)
{
id.innerHTML="Ooops!";
}
</script>
</head>
<body>
<h1 onclick="changetext(this)">Click on this text</h1>
</body>
</html>


HTML 4.0 Event Handlers


Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT. The time now is 04:08 PM.


Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.0
Ad Management by RedTyger
eXTReMe Tracker