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

  • Home
  • SEARCH
  • 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 6049245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:33:14+00:00 2026-05-23T07:33:14+00:00

I’ve been working on a Javascript library, one with basic functionality. I’m fairly new

  • 0

I’ve been working on a Javascript library, one with basic functionality.

I’m fairly new to Javascript, and am weaning myself off of jQuery, mainly for the sake of self-improvement.

My goal is to have a javascript library compatible with IE 8+, so I’m looking for browser-specific gotchas.

One specific problem is my event module, which doesn’t seem to work when I try to add multiple events to one selector in Firefox 4.

Here’s the module in question:

And the rest of the library is at github: https://github.com/timw4mail/kis-js/blob/master/kis.js

 (function(){

    var attach, remove, add_remove, e;

    if(document.addEventListener)
    {
        attach = function(sel, event, callback)
        {
            if(sel.addEventListener)
            {
                sel.addEventListener(event, callback, false);
            }
        };

        remove = function(sel, event, callback)
        {
            if(sel.removeEventListener)
            {
                sel.removeEventListener(event, callback, false);
            }
        };  
    }
    else
    {
        attach = function(sel, event, callback)
        {
            if(sel.attachEvent)
            {
                sel.attachEvent("on"+event, callback);
            }
        };

        remove = function(sel, event, callback)
        {
            if(sel.detachEvent)
            {
                sel.detachEvent("on"+event, callback);
            }
        };
    }

    add_remove = function (sel, event, callback, add)
    {
        var i,len;

        if(!sel)
        {
            return false;
        }

        //Get the DOM object if you give me a selector string
        if(typeof sel === "string")
        {
            sel = $(sel);
        }

        //Multiple events? Run recursively!
        event = event.split(" ");

        if(event.length > 1)
        {
            console.log(event);

            len = event.length;

            for(i=0;i<len;i++)
            {
                add_remove(sel, event[i], callback, add);
            }

            return;
        }

        //Check for multiple DOM objects
        if(sel.length > 1)
        {
            len = sel.length;
            for(i=0;i<len;i++)
            {
                (add === true)
                    ? attach(sel[i], event, callback)
                    : remove(sel[i], event, callback);
            }
        }
        else
        {
            (add === true)
                ? attach(sel, event, callback)
                : remove(sel, event, callback);
        }
    };

    e = {
        add: function(sel, event, callback)
        {
            add_remove(sel, event, callback, true);
        },
        remove: function(sel, event, callback)
        {
            add_remove(sel, event, callback, false);
        }
    };

    window.$_.event = e;

 }());
  • 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-23T07:33:15+00:00Added an answer on May 23, 2026 at 7:33 am

    Okay, after a while of searching, I found the problem is not with your library at all, but is with your test code. The problem is that innerText doesn’t work in Firefox 4. A version of your test code, updated to use innerHTML instead of innerText, works perfectly.

    Also, your library has some other compatibility issues that I thought I should point out:

    sel.addEventListener(event, callback, false);
    

    and

    sel.removeEventListener(event, callback, true);
    

    should have matching parameters for their third argument.

    Quote from MDC wiki:

    If a listener was registered twice, one with capture and one without, each must be removed separately. Removal of a capturing listener does not affect a non-capturing version of the same listener, and vice versa.

    And also, another compatibility thing (for IE8 or below): attachEvent expects you to have “on” before the event name, like so: element.attachEvent("onmouseover", function(){...});

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.