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 7584553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:57:01+00:00 2026-05-30T18:57:01+00:00

How to overcome event handlers being overridden? I have a script say a.js window.onload

  • 0

How to overcome event handlers being overridden?
I have a script say a.js

window.onload = function () {
   //Handler in a.js
}

Another script say b.js

window.onload = function () {
   //Handler in b.js
}

where,

a.js is a kind of 3rd party library built by me

b.js is a publisher who uses my script [I can’t do any changes out here]

Will onload handler in b.js override a.js’s handler?

If yes, How to prevent this from happening?

Will building a queue of all event handlers in a.js and deque them on event help?

But will a.js know all event handlers for an event upfront untill b.js is loaded?

Thoughts and references would help.

  • 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-05-30T18:57:02+00:00Added an answer on May 30, 2026 at 6:57 pm

    Use element.addEventListener or window.attachEvent in down-level IE versions.

    Sample addEvent method:

    function addEvent(node, type, listener) {
        if (node.addEventListener) {
            node.addEventListener(type, listener, false);
            return true;
        } else if (node.attachEvent) {
            node['e' + type + listener] = listener;
            node[type + listener] = function() {
                node['e' + type + listener](window.event);
            }
            node.attachEvent('on' + type, node[type + listener]);
            return true;
        }
        return false;
    };
    

    Note – Most, if not all, modern JavaScript libraries like jQuery and MooTools have their own implementations. I recommend leveraging their API’s – as they abstract out different browser implementations and have been thoroughly tested.

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

Sidebar

Related Questions

In my Qt application in the event handler for mouse press events I have
Does anyone have a method to overcome the 260 character limit of the MSBuild
Is there any solution to overcome case-sensitive problem for contains method. I have code
I have couple of objects(1 custom object called appointment and event object) which i
I have a jqGrid with multiselect:true. In a click event of a button I
I am applying draggable event of jQuery UI library to a popup window. Dragging
I have got this event in my page aspx.cs: public void deleteBtn_Click(object sender, CommandEventArgs
I have the following code as part of a jquery script to open a
I have a WPF program built in C#, and part of it's function is
How can I load an external JavaScript file using a bookmarklet? This would overcome

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.