The method selObj.fireEvent is undefined and cannot be executed

There is a function in a JavaScript file that retrieves a menu tree when users click on the parent item:

function menusel(unid) 
{   
    //if its in the array, deactivate it and take it out
    var index = inarray(unid,selectedarray);

    //first arrange the array
    if(index)
    {
        selectedarray[index] = 0;
    }
    else
    {
        //we have restrictions
        if(treeRestrictMode==1)
        {
            //now check its not in the array of items not allowed to be picked
            if(inarray(unid,nonSelArr))
            {
                alert('This Item is Unselectable'); 
                return;
            }       
        }
        
        //if we are in unique tree mode, can only select one
        if(treeSingleMode==1)
        {       
            //check for a non-zero value, and deselect it [recursively]
            for(var x=0;x<selectedarray.length;x++)
            {
                if(selectedarray[x]!=0)
                {   
                    menusel(selectedarray[x]);
                }
            }
        }
        
        selectedarray.push(unid);
    }
    
    sel_unselect(unid,index);

    //if there is an override function, assume that the parent page has an input type function called treeSelFunc which takes the id and completes the rest
    if(overrideFunction!='')
    {
        parent.parent.treeSelFunc(unid,selName);
        return;
    }

    if(treeSingleMode!=1)
    {
        var selObj = emptySel(0);//set txt will fill it for us
    }
    else
    {
        var selObj = parent.parent.MM_findObj(selName);
        
        //see if we have options..will need to empty them
        if(selObj.size>1)
        {
            emptySel(1);
        }
        else
        {
            selObj.value=0;
        }
        
    }
    setTxt(selObj);
    selObj.fireEvent('onchange');   
}

This function is called on a page like this:

<a id="troot[VMENU]_040" onclick="menusel(40);" class="sel">All</a>

But the following error is occurring: Uncaught TypeError: selObj.fireEvent is not a function

It used to work on an older browser version (possibly with Internet Explorer 8), but now it doesn't work on Chrome. Any ideas why?

Answer №1

Looking for an alternative to the standard EventTarget.dispatchEvent() method? Consider using the proprietary Microsoft Internet Explorer fireEvent method.

But remember, it's recommended to use the dispatchEvent method instead for better compatibility.

Learn more about EventTarget.dispatchEvent here

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The configuration of the Braintree API client is incorrect: the clientApiUrl found in the clientToken is not valid

Error Found: Braintree API Client Misconfiguration - The clientApiUrl provided in the clientToken is invalid. Upon checking my browser log, I noticed this error. I am using a Node backend with an Angular front end and integrating Braintree javascript SDK ...

Angular Date Filtering to Show dd-mm-yyyy Format

I am having trouble filtering the date correctly in my controller. My desired date format is Thu Mar 31 2016 05:05:00 GMT-0400 (EDT). However, when I use the code mentioned above, the results show up as 03-31-2016. This is the code snippet from my contr ...

JavaScript: A step-by-step guide to extracting the file name and content from a base64 encoded CSV

I have a base64 string that was generated by encoding a csv file, const base64 = 'LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLTExNDc2MDgwNjM5MTM4ODk4MTc2NTYwNA0KQ29udGVudC1EaXNwb3NpdGlvbjogZm9ybS1kYXRhOyBuYW1lPSJmaWxlIjsgZmlsZW5hbWU9ImNoYXJ0T2ZBY2NvdW50LmNzd ...

Utilizing Ionic Storage to set default request headers through an HTTP interceptor in an Angular 5 and Ionic 3 application

I'm attempting to assign a token value to all request headers using the new angular 5 HTTP client. Take a look at my code snippet: import {Injectable} from '@angular/core'; import {HttpEvent, HttpInterceptor, HttpHandler, HttpRequest} from ...

Rearrange DIV elements by clicking a button that redirects you to a different webpage

Consider a scenario with two distinct pages: website.com/page1 website.com/page2 Page 1 contains multiple buttons, each leading to Page 2. On Page 2, there are various content sections (divs). Is there a straightforward meth ...

Is it possible for me to convert a .map array into a comma-separated array enclosed in double quotation marks?

I am attempting to extract data from a group of twig variables and convert them into a javascript plugin. The data consists of dates listed in an array format. Initially, they are displayed on the template as a string like this: {"date":"2018-08-30, 2018- ...

I attempted to initiate a transition using JavaScript, but unfortunately it failed to execute

Hey there! I'm just starting out with HTML, CSS, and JavaScript, and I've been trying to make a transition work using JavaScript. The element I'm working with is a "menu-icon" which is a span tag with a small image nested inside another div ...

Having issues getting Nunjucks templates to render correctly in Express

There seems to be an issue with setting up the template hierarchy in Express or possibly an error in how Nunjucks is being utilized. The goal is to have a template that includes common parts and specific pages that extend this template. It appears that the ...

Is it possible for me to bring in/need the Kik.js document instead of using the Kik Card?

Currently working on a mobile web app designed for Kik. Their documentation advises including the Kik.js file directly in your HTML like this: <!-- simply include this script in your webpage --> <script src="http://cdn.kik.com/kik/2.3.6/kik.js"&g ...

What could be preventing the background color from changing when attempting to use style.backgroundColor?

My objective is to store the current tab background color in a variable and then use that variable to change the body color. However, for some reason it is not working as expected. Can you help me figure out why? const tabName = 'someId'; var ...

Is it feasible to incorporate an external library as a script within a class or functional component in React?

Welcome and thank you for taking the time to read this question! I am currently working on a project where I need to load a TIFF image. After researching, I found a library that can help with this task: https://github.com/seikichi/tiff.js There is also ...

What could be causing the JSON String decode error to occur while utilizing extjs ajax?

Here is an example of my code: Ext.Ajax.request({ url:'test.jsp', params:{id:id,password:password}, success:function(response){ console.log(response); var results = Ext.util.J ...

Switch effortlessly between one animation and another with Angular.js

I have two animations named "prev" and "next". Upon clicking the prev button, the "prev" animation should play. Similarly, when you click on the "next" button, the "next" animation should be triggered. I am using ng-class to achieve this behavior. How can ...

Display numerical data at precise locations above an image

Currently, I am working on a project where I am adding multiple marker pins to an image and saving their positions (x and y coordinates) to a database for later use. To see the code I have written so far, you can visit this link: https://jsfiddle.net/at3w ...

Filter and select JavaScript objects based on the content of an array

I have a challenge filtering specific fields from a set of JavaScript objects: A= [{ asset_bubble: 17, biodiversity_loss: 15, code: "CH", critical_information: 14, cyber_attacks: 19, data_fraud: 13, de ...

Arranging data using jqGrid's Inline Editing Feature

Can the data on jqGrid be sorted directly on the client side while using inline editing? It appears that the data is not being sorted when the row is editable, even if the row header is clicked. ...

"Exploring the symbiotic relationship between Node.js and Express.js: an

I recently started learning Node.js and Express.js. I used the Express.js executable (express) to create an express application, which generated the following lines in app.js: ... var app = express(); http.createServer(app).listen(app.get('port' ...

Can the height of one div be determined by the height of another div?

Here's the specific situation I am facing: I want the height of Div2 to adjust based on the content of Div3, and the height of Div3 to adapt based on the content in Div2. The height of Div1 is fixed at 500px. Some of the questions that arise are: I ...

Displaying an error message in the designated errors div is necessary when the regular expression does not produce a match

Is there a way to display an error message in the errors div when the jQuery match function returns false? <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link href="form.css"> ...

Managing ajax requests for lazy loading while scrolling through the middle of the window can be a challenging task. Here are some tips on

I have implemented Lazy loading in my Project. I found a reference at which explains how to make an ajax call after scrolling and image upload with slow mode without allowing scrolling until the loader is shown. The code snippet I am using is as follows: ...