Results 1 to 6 of 6

Thread: Why we use Events in JavaScript?

  1. #1
    Join Date
    Aug 2006
    Posts
    162

    Why we use Events in JavaScript?

    I am using events in the Javascript. But I don't know the exact purpose of using an event.!! Can someone explain me, that why we use Events in JavaScript? Also please tell me the different events that we use in the JavaScript. Since, I have started recently doing the JavaScript, I have not used the events much enough. It will be much better if someone can provide me the coding for the events that are used in JavaScript.!!
    Processor: AMD Athlon(tm) 64 X2 Dual Core @ ~2.2 GHz
    Memory: 1024MB RAM
    Hard Drive: 200 GB
    Video Card: RADEON X300/X550 Series

  2. #2
    Join Date
    Aug 2006
    Posts
    235

    Re: Why we use Events in JavaScript?

    You have the ability to create dynamic web pages by using the JavaScript. Events are actions that can be detected by JavaScript. In other words you can say that an events are the beating heart of any JavaScript application. You can't write scripts without using an event. When the user does something an event takes place. There are also some events that aren’t directly caused by the user: the load event that fires when a page has been loaded, for instance. Hope that you have understood the concepts of the events in JavaScript.
    3.2 (northwood)
    2gig ram
    ATI AIW X800xt 256mb
    Gigabyte GA-8knxp 875p Chipset
    Optiwrite 8X DVD Burner
    Win XP PRO Sp2 (Works Perfectly)
    2 SATA Raptor 74gig Raid 0
    2 7200 IDE 320gig HD

  3. #3
    Join Date
    Aug 2006
    Posts
    227

    Re: Why we use Events in JavaScript?

    I think that looking at some example will make you more easy to understand. I have explained you the Resize event. With the help of this event we can detect whenever the window is being resized by the user. Following script demonstrates the Resize event :
    Code:
    <html>
    <head>
    <script language="JavaScript">
    
    window.onresize= message;
    
    function message() {
      alert("This window has been resized!");
    }
    
    </script>
    </head>
    <body>
    So resize the window.
    </body>
    </html>
    I do to dead flowers what people at morgues do to dead people. Suck all the moisture out, dip them in plastic, paint them up pretty and put them in a nice frame.

  4. #4
    Join Date
    Jul 2006
    Posts
    442

    Re: Why we use Events in JavaScript?

    Every element on a web page has certain events which can trigger a JavaScript. When the user takes action he causes an event. When your script makes the page react to this event, interactivity is born. The following are the examples of events that are used in JavaScript :
    1. A web page or an image loading.
    2. Mousing over a hot spot on the web page.
    3. A mouse click.
    4. Selecting an input field in an HTML form.
    5. A keystroke.
    6. Submitting an HTML form.
    "When they give you ruled paper, write the other way..." J.R.J.

  5. #5
    Join Date
    Jul 2006
    Posts
    286

    Re: Why we use Events in JavaScript?

    The onLoad and onUnload events are triggered when the user enters or leaves the page. And the onFocus, onBlur and onChange events are often used in combination with validation of form fields. Any script that uses navigator.userAgent for event model detection is worse than useless and should be laughingly dismissed. A script using the Microsoft all container can safely be executed. For writing an event handler, the first step is registering your event handler. Event object contains properties which describe an event. Every time an event occurs an Event object is passed to the event handler.
    IF you hate me, please don't mention it. I know who hates me and who doesn't. You really do not have to make fun of people....

  6. #6
    Join Date
    May 2008
    Posts
    2,389

    Re: Why we use Events in JavaScript?

    The onSubmit event is used to validate ALL form fields before submitting it. The function checkForm() returns either true or false. If it returns true the form will be submitted, otherwise the submit will be canceled. The following is an example, for the same :
    Code:
    <form method="post" action="trial.htm" onsubmit="return checkForm()">
    If you want to create "animated" buttons, then you can use onMouseOver and onMouseOut.

Similar Threads

  1. All day events one day out
    By Steadfast in forum Portable Devices
    Replies: 4
    Last Post: 13-10-2010, 11:22 AM
  2. Javascript Keyboard Events In Iframe
    By Henryosa in forum Software Development
    Replies: 5
    Last Post: 25-01-2010, 02:04 PM
  3. Explain the Timing Events in JavaScript
    By Shaan12 in forum Software Development
    Replies: 5
    Last Post: 19-12-2009, 05:41 AM
  4. What are the different Events in the Javascript?
    By Sheena_thakkar in forum Software Development
    Replies: 5
    Last Post: 18-12-2009, 08:07 AM
  5. What are those controls that do not have events?
    By Chandrakant81 in forum Software Development
    Replies: 3
    Last Post: 27-02-2009, 10:40 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,508,643.49530 seconds with 17 queries