Error (CODE5022) JavaScript detected in Internet Explorer 10

Here is the code that I wrote:

AjxException.reportScriptError =
 function(ex) {
if (AjxException.reportScriptErrors && AjxException.scriptErrorHandler && !(ex    
       instanceof AjxException)) {
    AjxException.scriptErrorHandler(ex);
}
throw ex;
};

This code works fine in all browsers, including IE9 and IE8. However, when testing in IE10, I encountered the following error:

 SCRIPT5022: InvalidCharacterError 

The error specifically pointed to throw ex;. Can anyone explain why this happens in IE10 and suggest a solution?

Answer №1

After some investigation, I finally identified the issue with the code: the javascript was originally designed for older versions of internet explorer: IE7, IE8, IE9 and included this line:

var ninput = document.createElement(AjxEnv.isIE ? ["<INPUT type='",type,"'>"].join("") :  
"INPUT"); 

This code successfully created an INPUT element in earlier versions of IE but did not work in IE10. Therefore, I had to make a modification to accommodate for this:

var ninput = document.createElement((AjxEnv.isIE && !AjxEnv.isIE10up)? ["<INPUT type='",type,"'>"].join("") : "INPUT");

Now, the code is functioning properly.

Answer №2

Have you checked if your files are saved without a BOM (Byte Order Mark)? Including a BOM can often cause issues with parsers and create chaos.

I would also suggest breaking up your code into as many lines as possible to pinpoint the line causing trouble. By removing that line for testing purposes, you can quickly identify the problem.

For instance, it's possible that you may be using an object of the wrong type (such as working with an array when the object is actually a string). If removing an object resolves the issue (or improves it), consider using

alert('typeof myObject = '+typeof myObject);
for additional insight.

Additionally, it seems like there are multiple occurrences of ex in your code. Double check to ensure you aren't using both a string and a function named ex.

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

Is there a way to specify the dimensions of the canvas in my image editing software based on the user-input

Here is the code and link for my unique image editor. I would like to allow users to enter the desired width and height of the selection area. For example, if a user enters a width of 300 and height of 200, the selection size will adjust accordingly. Addit ...

Navigating Pre-Fetched Client Routes in Gatsby with @ReachRouter

Let's consider this scenario. Imagine a user enters /company/<company-id> in the address bar. Because the app is completely separate from the backend, it must prefetch the companies. The usual flow is /login -> /company/. Handling this sequ ...

Can we modify the styling of elements in Angular based on an object property?

I have a class named Task with the following properties: export class Task { name: string; state: number; } Within my component.ts file, I have an array of objects consisting of instances of the Task class (tasks). When displaying them in the tem ...

Guide on invoking an Angular 1.5 component with a button press

Having just started learning Typescript, I'm struggling to figure out how to call my Angular component "summaryReport" on a button click. Here's a snippet of my code: Let's say I have a button that should call my component when clicked with ...

Guide on inserting HTML text box form input into Express route parameter

I'm currently working on implementing a feature that allows users to search through my mongo database using an endpoint structured like this: app.get('/search/:input', function(req, res){ console.log(`get request to: /members/${req.params ...

Extract JSON data from a web address using JavaScript

A unique system has been created to parse JSON and style it using CSS. Instead of outputting the data within the script, the goal is to retrieve data from a local or remote URL. <script type='text/javascript'> $(window).load(function(){ va ...

Retrieve the specific array element from parsing JSON that includes a particular phrase

I need help filtering array values that contain the phrase 'Corp' Currently, all values are being returned, but I only want the ones with "Corp" var url = "/iaas/api/image-profiles"; System.debug("getImageProfiles url: "+url ...

Generating input fields dynamically in a list and extracting text from them: A step-by-step guide

I am designing a form for users to input multiple locations. While I have found a way to add input boxes dynamically, I suspect it may not be the most efficient method. As I am new to this, I want to ensure I am doing things correctly. Here is how I curren ...

Exploring JSON data in JavaScript

In my Json data, I have a nested structure of folders and files. My goal is to determine the number of files in a specific folder and its sub-folders based on the folder's ID. Below is an example of the JSON dataset: var jsonStr = { "hierarchy": ...

Is your Discord bot failing to log on?

I created a discord bot, but I'm having trouble getting it online. There are no errors and I'm not sure why. Here is my code: const TOKEN = "MyBotsToken"; const fs = require('fs') const Discord = require('discord.js'); const C ...

The error message "MongoDB encountered an issue with accessing the property 'push', as it was undefined."

Exploring node.js, express and MongoDB is a learning journey for me. While working on data association in MongoDB models, I encountered a runtime error. Even though the reference has been added to the model, the push() method fails to recognize it. Here ar ...

Displaying numerous database rows through SQL with the aid of PHP and JavaScript (specifically AJAX) on the frontend of a website

I am a beginner in the world of PHP and JavaScript (Ajax) and despite my efforts to find a solution by looking at various posts and websites, I have not been successful. My goal is to display all related database rows on the front end of a website. While ...

tips for effectively coordinating functions with promises in node.js

Hey there! I'm currently working on synchronizing my functions by converting callbacks to promises. My goal is to add the post.authorName field to all posts using a forEach loop and querying the user collection. Initially, I attempted to use callb ...

When utilizing Md-select in Protractor, how can the dropdown list be accessed?

I am having trouble locating the option from the dropdown menu that I need to select. Despite trying various methods, I have not been successful. <md-select ng-model="card.type" name="type" aria-label="Select card type" ng-change="$ctrl.onCardSelecti ...

Solving the Issue of Assigning a Random Background Color to a Dynamically Created Button from a Selection of Colors

Trying to create my own personal website through Kirby CMS has been both challenging and rewarding. One of the features I'm working on is a navigation menu that dynamically adds buttons for new pages added to the site. What I really want is for each b ...

Tips for adding a dynamic variable into a react JSX map function

I have a component that receives a props with the value of either 'A', 'B', or 'C' based on the selection made in the parent element. The challenge is to use this props to dynamically select an option list locally, instead of ...

Unable to attach trigger click event to SVG path element

Unable to simulate a click on an SVG path element, even though other actions like remove() are functional. The following code snippet is not functioning as expected: $("#parentelement").on("click", "someelement", function() { $('g path[data-co ...

Using Jest: A guide to utilizing a mocked class instance

When working on my frontend React application, I decided to use the auth0-js library for authentication purposes. This library provides the WebAuth class which I utilize in my code by creating an instance like so: import { WebAuth } from 'auth0-js&ap ...

The problem with Ajax functionality

I've gone over my code multiple times, but I can't seem to find where I went wrong. Whenever I click the button, it fails to retrieve the file from my generate.php. INDEX.PHP <html> <head> <title>Title</title> ...

Unexpected provider error in AngularJS when using basic module dependencies

I am encountering an issue with my module setup involving core, util, and test. The util module has no dependencies and one provider The test module depends on util and core, and has one controller The core module depends on util, and has a provider that ...