Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7927643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:25:14+00:00 2026-06-03T19:25:14+00:00

I am trying to express what I understood from reading some articles about dom0

  • 0

I am trying to express what I understood from reading some articles about dom0 event model in JavaScript. If there is a mistake in it, please correct me.

In dom0 model, an event handler can be attached to an element. Only one handler can be attached. When the event occurs, the browser calls that event handler.

There are two ways of doing this:

1.Inline model

The handler is added as an attribute of the element.For example a link element (i.e. <a>) has an attribute called onclick. We add a function hello like this:

<a href="#" onclick="hello();"> say hello </a>
...
<script type="text/javascript">
   function hello(){
      window.alert("Hello");
   }
</script>

The problem with this model is that it is intrusive, since the hello() is put in the body of the element.

2.traditional model

Instead of adding event handler as attribute of element in the body of the element,the adding/removing of handler is done by script. The handler is assigned to the element’s property as below:

<a href="#" id="hellolink">  say hello </a>
...
<script type="text/javascript">
    function hello(){
        window.alert("Hello");
    }
    //adding handler
    document.getElementById('hellolink').onclick=hello;
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T19:25:23+00:00Added an answer on June 3, 2026 at 7:25 pm

    Seems about right.

    You might want to read:
    http://www.cross-browser.com/talk/event_interface_soup.php
    http://en.wikipedia.org/wiki/DOM_events#Traditional_model

    and for the code in the traditional model you should have a a window.onload event

    so

    window.onload = function () {
    
        var el = document.getElementById('hellolink');
        if (el) {
            el.onclick = hello;
        }
    };
    

    depending on what browser you are using function hello might receive the element object, so maybe it’ll easier for you if you use something like jQuery to handle your dom events.

    http://api.jquery.com/click/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm trying to set up some tables in my SQL Express server, and i
I'm trying to install the dependencies of some example: npm's express 2.5.8 that I've
I’m trying to import fixed width data from text file into SQL Server Express
I'm trying to port a database from SQL Server Express over to my MySQL
I'm trying to connect to SQL Server 2008 express database from Visual Studio 2010
I am trying to connect to SQL Server 2005 express edition from SQL Server
When trying to inline a function in Visual C++ (2008 express), I got a
I'm trying to connect to a MS SQL Server 2005 Express database that is
I'm trying to make a connection to a SQL Server Express DB on localhost,
I’m trying to bulk insert data to SQL server express database. When doing bcp

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.