Error with decodeURIComponent function in Internet Explorer 8

My widget, loaded as an iframe, requires data about the hosting page. I have UTF-8 strings extracted from a page with Russian text. The page itself has proper HTML5 doctype and meta charset.

This is how my code operates:

params = "x1=" + encodeURIComponent(s1) + "&x2=" + encodeURIComponent(s2)
url = "http://mysite.com/iframe.html#" + params

create_iframe(url)

The create_iframe function looks something like this:

var $if, doc;

$if = $('<iframe>').attr({
  frameborder: 0,
  scrolling: "no",
  allowtransparency: "true"
}).css(css).appendTo($cont);

doc = $if[0].contentWindow.document;

doc.open().write("<head><meta charset=\"UTF-8\"><script>" +
    "var s = \"" + url + "\";" + // <--- here the url is injected into the iframe content
    "function init() { document.location.href = s; }" + 
     "</script></head><body onload=\"init();\">...</body>");

doc.close();

We use jQuery to generate an iframe and then write to its content to load our url.

Once the "" URL loads within the iframe, the script contained in it retrieves the parameter values from the hash:

var hash_index, loc, param, params, params_array, params_string, tmp, _i, _len;

loc = document.location.href;
hash_index = loc.indexOf('#');
if (hash_index >= 0) {
  params_string = loc.substring(hash_index + 1);
}
params_array = params_string ? params_string.split('&') : [];
params = {};
for (_i = 0, _len = params_array.length; _i < _len; _i++) {
  param = params_array[_i];
  tmp = param.split('=');
  params[tmp[0]] = decodeURIComponent(tmp[1]);
}
return params;

This process works smoothly in Chrome.

In IE8, I encounter an error indicating invalid encoding when attempting to decode the URI.

What steps should I take to resolve this issue?

Answer №1

Internet Explorer is cutting off lengthy URLs when they consist of 2 UTF-8 bytes or more.

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

JavaScript Animation of Text

I have a challenge where I want to animate text's opacity in JavaScript after the user presses enter. However, I am struggling to achieve this with my current code. I can provide all of my code for you to review and help me understand why the animatio ...

Guide on generating a dynamic table by looping through an array and placing values inside <tr> tags, then saving it in a variable

I am working with an array object and need to dynamically create a table where each tablerow (tr) pulls values from the array object. After creating the table, I want to store it in a variable so that I can pass it to a rest call, triggering an email with ...

Encasing a variety of child elements within a div container

My goal is to group a range of children elements within a div so that I can manipulate them collectively in different locations. The challenge arises from having a list with randomly generated li tags, and no matter how many appear, I need every batch of t ...

Showing a collection of objects in a React component

**Recently started learning React and Node, and decided to fetch data into a functional component by following various tutorials. I successfully set up the server, connected it to the database, and fetched the data in React as per the tutorial instruction ...

Having trouble initializing and retrieving an array from the controller in AngularJS

I tried to set up and retrieve the array values from the controller. Check out the fiddle here. var app = angular.module('carApp', []); app.controller('carAppCtrlr', function ($scope) { $scope.vehicles = [{ type: ' ...

Issue TS1259: The module "".../node_modules/@types/bn.js/index"" can only be imported as the default using the 'esModuleInterop' flag

Currently, I am utilizing Hiro Stack.js which I obtained from the following link: https://github.com/hirosystems/stacks.js/tree/master/packages/transaction. For additional information, please refer to . Even when attempting to compile a fully commented out ...

What exactly is the significance of the code snippet "var data = jQuery(msg), script;" in JavaScript?

this snippet is extracted from a Google Chrome extension "search" == request.ajax && $.ajax({ url: request.url, type: "GET", dataType: "html" }).done(function(msg) { if (msg.indexOf("https://login.testabc.com/ ...

Ways to categorize specific columns based on certain criteria

In the code snippet below, I am working with a data grid in premium version. There is a boolean field that determines whether to display the data grouped or inline. If the boolean is true, I want to show the expand group, otherwise display it inline withou ...

What steps should I follow to enable a tooltip in this specific situation using qtip?

In my database, I have tables for venues, venue types, and map icons with the following relationships: A venue belongs to a venue type A venue type belongs to a map icon Each venue result is shown on the index page as a partial. Each partial ...

What is the most efficient method for transferring Flask variables to Vue?

I am currently developing a visualization application using a flask server and vue.js for the front end. Other discussions on this topic explore how to avoid conflicts between vue.js and flask variable syntax, as shown here. In my scenario, I'm inte ...

Ways to prevent prop changes from passing up the chain?

After some experimentation, I discovered that the props I passed to a component can actually be changed within the component and affect the parent. This behavior is discussed in the official documentation. While objects and arrays cannot be directly modi ...

Correctly align the div on the screen as the viewport is scrolled

I am currently working on a parallax website where the sliders are designed to slide from the left and align within the viewport as the user scrolls. However, I have encountered an issue where multiple scroll actions are required for the slide to align pro ...

What is the proper way to send a list of lists from Ajax to Flask?

Attempting to send a list of list datatype data from a template using AJAX. Here is the code: Template (JS) var mydata = [['tom', 18, 'new york'], ['jack', 16, 'london']]; var data = new FormData(); mydata.forEach( ...

The functionality of the AJAX Script is failing to load properly on mobile devices

Currently, I am undertaking a project that involves ESP32 Arduino programming to create a webpage where users can interact with buttons to activate relays. Additionally, I have implemented a slider using a short script. This project is inspired by the ESP3 ...

Codeigniter not functioning properly with Ajax

I am trying to implement this javascript function $('a[name=deleteButton]').on('click', function () { arr=[]; var arr = $("input[name='post[]']:checked").map(function() { return this.value; }). ...

Encountering an issue of THREE.EventDispatcher being undefined while trying to create a THREE.OrbitControls instance using THREE.js, THREE.OrbitControls, and TypeScript

Attempting to delve into typescript alongside three.js, I've encountered a perplexing error that has me stumped. The root of the issue lies within the init function where I initialize a new THREE.OrbitControls controller. Utilizing the setup provided ...

What is the most effective way to integrate webkitSpeechRecognition into a Vue.js project?

I found a demo at this link, but I'm having trouble understanding it. Can you provide a simple implementation? <div id="app"> <v-app id="inspire"> <v-container fluid> <v-layout row wrap justify-cen ...

Develop a responsive shopping cart using PHP and JavaScript

I am in the process of developing an ePos system that allows users to add items to their basket by simply clicking on them, and then calculates the total price without needing to refresh the entire page. I initially attempted to use $_SESSION and store th ...

Add objects to a web address that leads nowhere but can still be linked to

It has come to my realization that the vagueness of my question might be obstructing my search efforts online. Here is the scenario: I am aiming to create a URL structure like this: http://app.myurl.com/8hhse92 The identifier "8hhse92" does not correspo ...

Capture a snapshot of a webpage that includes an embedded iframe

Currently, we have a nodeJS/angular 4 website that contains an iframe from a third party (powerBI Emebdded). Our goal is to develop a feature that allows the end user to capture a screenshot of the entire page, including the content within the iframe. We ...