Using solely JavaScript, the process of eliminating parameter values from a URL on the subsequent page

Seeking assistance in removing the values from the URL after the "?" once transitioning to the next page from the initial page. Despite multiple attempts, I have been unable to find the correct solution. Any help would be greatly appreciated.

Desired URL Structure:

file:///C:/Users/varun.singh/Desktop/www%20updated%2027.8.2015%20Old/www/Candidates/newOne.html?

Current URL Format:

file:///C:/Users/varun.singh/Desktop/www%20updated%2027.8.2015%20Old/www/Candidates/newOne.html?Name=Name%201&JobTitle=Title%201&Date=Entered%20Date%201

listItem.onclick = function(){  


        var elementData=listData[this.id];
        var stringParameter= "Name=" + elementData.name +"&JobTitle="+elementData.job_title+"&Date="+ elementData.entered_date;

      //window.location.href = window.location.href.replace("ListCandidateNew", "newOne") + "?" + stringParameter;
       window.location.href="file:///C:/Users/varun.singh/Desktop/www%20updated%2027.8.2015%20Old/www/Candidates/newOne.html?"
                + stringParameter;
}

Answer №1

Here is a solution that should do the trick:

let fileUrl = 'file:///C:/Users/varun.singh/Desktop/www%20updated%2027.8.2015%20Old/www/Candidates/newOne.html?Name=Name%201&JobTitle=Title%201&Date=Entered%20Date%201';

    let indexPos = fileUrl.lastIndexOf("?");

    fileUrl = fileUrl.slice(0, indexPos + 1); // including "?"

Answer №2

Big thanks to everyone who took the time to try and help me with my issue. After some trial and error, I managed to find a solution using window.sessionStorage to keep the string parameter alive for passing values. Here's the complete code snippet:

For transferring values between two pages, I utilized ListCandidateNew.html and newOne.html.

ListCandidateNew.html

listItem.onclick = function() {
    var elementData = listData[this.id];
    var stringParameter = "Name=" + elementData.name + "&JobTitle=" + elementData.job_title + "&Date=" + elementData.entered_date;

    window.sessionStorage['Name'] = elementData.name;
    window.sessionStorage['JobTitle'] = elementData.job_title;
    window.sessionStorage['Date'] = elementData.entered_date;
}

newOne.html

function LoadCandidateDetail() {  
    document.getElementById('Name').innerHTML = window.sessionStorage['Name'];
    document.getElementById('JobTitle').innerHTML = window.sessionStorage["JobTitle"];
    document.getElementById('Date').innerHTML = window.sessionStorage["Date"];
}

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

Transform a Div element into an image, ensuring compatibility with Internet Explorer 7 and 8

Currently, I am utilizing the jqplot charting library to create charts in my ASP.NET MVC application. Within a div element, the chart is being rendered. The goal is to convert this div element into an image and export it to a PDF document. The jqplotToIm ...

The creation of the Angular project was unsuccessful due to the outdated circular-json dependency

After attempting to create a new Angular project with the command: ng new hello-world I encountered an error message: npm WARN deprecated <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b5d6dcc7d6c0d9d4c798dfc6dadbf5859b809b8 ...

Unable to establish a connection with the TCP server on CloudFoundry, although the localhost node.js is functioning properly

I am experiencing difficulty connecting to my TCP server example that is running on CloudFoundry. Interestingly, when I run my app.js file on a local node.js installation, everything works perfectly. Upon using vmc push to deploy on CloudFoundry, the servi ...

Instructions on how to extract a specific timestamp from a video and utilize it to initiate an event

Is there a way to trigger an event or animation at a specific time in a video or frame of the video? For instance, I want text to appear when a video reaches 30 seconds. I've experimented with currentTime, tried using loadeddata, and attempted to u ...

Determine the position and quantity of elements in jQuery by comparing their IDs with the current page or element

Looking to retrieve the n (zero based) position of an element by matching the page and element ID... Let's use an example (Assume the current page ID is 488); <ul id="work-grid"> <li id="item-486" class="work-item"><!--/content--& ...

IE displaying "slow script" alert due to Knockout malfunction

Within my grid of observables and computed observables, the first row serves as a multiplier for all subsequent rows. Users can modify this percentage rate and Knockout automatically updates all relevant values accordingly. Additionally, I require a textbo ...

What could be causing my fixed header to disappear in Safari 5?

I am experiencing a strange issue with my fixed header on Safari 5 for iPad. The header disappears once it scrolls down to a certain point, even though it works fine in IE, Firefox, Chrome, and the latest version of Safari. Has anyone else encountered this ...

"Hey, getting an error stating 'require is not defined' while attempting to configure the .env file. Need some help here

I am currently working on setting up a .env file to securely store the credentials for my Firebase database within a vanilla JavaScript project. Despite following various tutorials and referencing the documentation for dotenv, I continue to encounter an er ...

Height setting for an ASP.NET UpdateProgress widget

In my ASP.NET Project, I am facing an issue with the UpdateProgress. I need the UpdateProgress to adjust its height dynamically based on the content within the UpdatePanel. I attempted to use a JQuery script to accomplish this, but the script does not run ...

Limiting the input of a user to a maximum of a five-digit integer with a maximum of two decimal points using Angular 2 and ngModel

Currently, I am working on an input text field that utilizes [(ngModel)]. My goal is to restrict users to entering only a maximum of 5 digits with up to 2 decimal places. I believe creating a directive is the best approach to achieve this, however, I am un ...

The XHR Get request fails to load the HTML content sent from the Express application

As I embark on building my inaugural express app, I have encountered a shift in sending requests from the front-end. Previously, all requests were initiated by anchor elements for GET requests and form elements for POST requests, with server responses hand ...

Flame-inspired CSS editor

My current CSS editing workflow goes something like this: I ask for feedback on a page Suggestions are given to make post titles bigger I use Firebug to inspect the post title element I locate the corresponding CSS statement in Firebug (like h2.post_title ...

Attempting to extract the cell information and choose an option from a cell using the Tabulator program

I've been using Tabulator, which is an amazing tool, but I've run into a little trouble. I'm trying to add an HTML Select in each row, with options specific to each record. When I change the select option, I call a function and successfully ...

executing a pre-existing executable file within a web browser or XAML Browser Application (

Currently, I have an application (let's call it exe1) provided by the supplier of our instruments that I would like to integrate into my existing application. Instead of rewriting exe1 from scratch, I am considering embedding it using something like a ...

Having difficulty modifying the styling of a paragraph within a div container

I have been working on a function that is supposed to adjust the font-size and text-align properties of a paragraph located within a div tag once a button is pressed. function customizeText() { document.getElementById('centretext').innerHTML = ...

What could be causing the "keyframes method" in my css to not function correctly?

When working on the keyframes section, my computer seems to be having trouble recognizing the from part. Ideally, it should display in blue with the opacity command appearing in grey. Unfortunately, neither of these styles are appearing correctly and I&apo ...

Is it possible to minify HTML in PHP without parsing JavaScript and CSS code?

After finding a solution in this discussion, I successfully managed to 'minify' HTML content. function process_content($buffer) { $search = array( '/\>[^\S ]+/s', // eliminate spaces after tags, except for ...

Is it advisable to use Angular $resource JSON Callback if it's not functioning correctly?

I am in the process of creating a resource to send data to my controller for an existing API that I need to connect with. Unfortunately, I do not have the ability to make any changes on the backend. Current state of my Resource factory: 'use strict& ...

Implementing distinct click tracking with AngularJS

var app = angular.module('app', []); app.directive("eventsEvaluation", function() { return { restrict: "E", template: "<div>" + "<span class='span' type='number' data-ng-bind='number'> ...

The type x cannot be assigned to the parameter '{ x: any; }'

Currently learning Angular and Typescript but encountering an error. It seems to be related to specifying the type, but I'm unsure of the exact issue. Still new at this, so any guidance is appreciated! src/app/shopping-list-new/shopping-edit/shopp ...