On the Details page, use the URL object to get access to the url params, for example:

const url = new URL(window.location.href);
console.log(url.searchParams.get("id"));
Answer from Petr Broz on Stack Overflow
๐ŸŒ
Bobby Hadz
bobbyhadz.com โ€บ blog โ€บ redirect-to-another-page-with-parameters-using-javascript
Redirect to another Page with Parameters using JavaScript | bobbyhadz
March 7, 2024 - Set the window.location.href property to redirect to the page with parameters. Here is the HTML for the example. ... Copied!<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> </head> <body> <h2>bobbyhadz.com</h2> <button ...
๐ŸŒ
EncodedNA
encodedna.com โ€บ javascript โ€บ redirect-to-another-page-with-multiple-parameters-in-javascript.htm
How to Redirect to another Page with Multiple Parameters in JavaScript
May 20, 2025 - const v1 = document.getElementById('book')?.value; const v2 = document.getElementById('b_name')?.value; if (!v1 || !v2) { console.error("Missing required parameters"); return; } const baseUrl = "https://www.encodedna.com/javascript/demo/"; const page = "check-if-url-contains-a-given-string-using-javascript.htm"; const params = new URLSearchParams({ book: v1, name: v2 }).toString(); window.location.href = `${baseUrl}${page}?${params}`; }; &lt/script> ... The above URL has two parameters "book" and "name", for I am extracting the values from the two input boxes. Let's execute the above code and see what happens. Click the button below to redirect to another page. See the URL after the page redirects. Similar example: how to redirect with multiple parameters in jquery
Discussions

Redirect to url with hidden parameters - JavaScript - SitePoint Forums | Web Development & Design Community
I have had to jump off a validation project Im doing onto something else within the same project, but for some reason Im having a bit of trouble with something that seems so simple. I want to redirect the user to the next page if theyre log in details match, and take with it the ID of the user, ... More on sitepoint.com
๐ŸŒ sitepoint.com
0
November 3, 2016
javascript - How to 3xx redirect and pass a value from a table as a query parameter (in the URL)? - Stack Overflow
0 Go to specific dynamic url on click in table with specific cell data reference - Jquery ยท 0 how to pass an table row object directly to another html page as url argument? 1 How to pass and get Parameters between two Pages in Jquery Mobile? 0 Redirect to a page and pass the query parameters ยท 0 how to redirect a page in javascript ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
javascript - Redirect to page and pass text and image parameter - HTML JS - Stack Overflow
I have a product page with 20 or so products on it. When you click on a product link I would like to pass 2 parameters to the page it redirects to, an image src and a text attribute and then display More on stackoverflow.com
๐ŸŒ stackoverflow.com
Get url params and redirect to url after
WARNING Because you are using URLs withing URLs, you might need to replace the special characters of the URL with encodeURIComponent(). More info on that here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent More on support.glitch.com
๐ŸŒ support.glitch.com
0
0
July 24, 2020
๐ŸŒ
Talkerscode
talkerscode.com โ€บ howto โ€บ how-to-redirect-to-another-page-in-javascript-with-parameters.php
How To Redirect To Another Page In JavaScript With Parameters
Setting the href attribute of the window.location object is the most popular approach to redirect a URL in JavaScript. This simulates navigating to a new page in the conventional way. I don't believe any task could be easier than this: simply create a new URL. In jQuery, the replace() function of the window.location object can also be used to redirect to a web page. The current URL is removed from the history and replaced with a fresh URL using this method.
๐ŸŒ
Tutorial and Example
tutorialandexample.com โ€บ javascript-redirect-url-with-parameters
JavaScript redirect URL with parameters - TAE
March 19, 2022 - โ€œurlโ€ is any address to the website or the document we want to redirect to. ... Here, we are passing a URL to google search โ€œjavatpointโ€ and โ€œcppโ€, hence the URL takes two parameters, <!DOCTYPE > <html > <head> <title>Javascript redirect URL</title> </head> <body> <h3>After taking multiple parameters though hardcoding, we have the following information that you need:</h3><br /><br /> <input type="button" value="Search" onclick="Submit()" /> <script type="text/javascript"> function Submit(){ const url = "https://www.google.com/search?q=javatpoint&q=cpp"; window.location.href = url; }; </script> </body> </html>
๐ŸŒ
GitHub
gist.github.com โ€บ code-boxx โ€บ 98665062718708a91d2fece507b8666d
Javascript Redirect With Parameters ยท GitHub
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window.
๐ŸŒ
Code Boxx
code-boxx.com โ€บ home โ€บ redirect with parameters in javascript (simple examples)
Redirect With Parameters In Javascript (Simple Examples)
July 3, 2023 - This tutorial will walk through examples of how to redirect with parameters in Javascript. Free example code download included.
Find elsewhere
๐ŸŒ
SitePoint
sitepoint.com โ€บ javascript
Redirect to url with hidden parameters - JavaScript - SitePoint Forums | Web Development & Design Community
November 3, 2016 - I have had to jump off a validation project Im doing onto something else within the same project, but for some reason Im having a bit of trouble with something that seems so simple. I want to redirect the user to the next page if theyre log in details match, and take with it the ID of the user, but hidden, but the redirect function isnt being called. if (data != 0){ var userID = data; $().redirect('index2.php', {'ID': userID}); }
๐ŸŒ
ScratchCode
scratchcode.io โ€บ home โ€บ redirect by javascript with example
Redirect By JavaScript With Example | Scratch Code
June 15, 2021 - In the above example, we are fetching the browser name using the navigator.appName and based on the browserโ€™s name we are redirecting to the appropriate page. Usually, we want to pass additional details with the URL which we have known as parameters or query strings.
๐ŸŒ
ASPSnippets
aspsnippets.com โ€บ Articles โ€บ 2793 โ€บ Redirect-to-another-Page-with-multiple-Parameters-using-JavaScript
Redirect to another Page with multiple Parameters using JavaScript
May 3, 2019 - explained with an example, how to redirect to another Page with multiple Parameters using JavaScript. The multiple values to be passed to another Page will be added to the URL as QueryString parameters and then the Page will be redirected to another Page using window.location property in JavaScript.
Top answer
1 of 2
1

To pass both parameters, you may try this

jQuery(document).ready(function($){
    $('.product').click(function(event) {
        event.preventDefault();
        var name = $(this).data('title'), img = $(this).data('img')
        window.location = './lineup/index.html?title=' + name + '&img=' + img;
    });
});

To parse a value by key from url you can use this function (Source : MDN)

function loadPageVar (sVar) {
    return decodeURI(window.location.search.replace(new RegExp("^(?:.*[&\\?]" + encodeURI(sVar).replace(/[\.\+\*]/g, "\\$&") + "(?:\\=([^&]*))?)?.*$", "i"), "$1"));
}

In your lineup/index.html put this code and the function given above

$(function(){
    $('#title-area').text(loadPageVar('title'));
    $('.product-img').text(loadPageVar('img')); // will set text

    // To set an image with the src
    $('.product-img').append($('<img/>', {
        'src':loadPageVar('img')
    }));
});
2 of 2
1

If you're looking for an alternative to URL query strings I'd look into window.sessionStorage object.

Store parameters like so:

$('.product').click(function(event) {
    event.preventDefault();
    window.sessionStorage.setItem('name', $(this).data('title'));
    window.sessionStorage.setItem('imgSrc', $(this).data('img'));
    window.location.reload(); //refreshes the page
});

Then to load the attributes, should they exist, add the following:

$(function(){
    if (window.sessionStorage.length){
        $('#title-area').text(window.sessionStorage.getItem('title'));

        $('.product-img').append($('<img/>', {
            'src':window.sessionStorage.getItem('imgSrc')
        }));
    }

    //include the click event listener for .product link here too
});
๐ŸŒ
Next.js
nextjs.org โ€บ docs โ€บ app โ€บ api-reference โ€บ functions โ€บ redirect
Functions: redirect | Next.js
3 weeks ago - By default, redirect will use push ... current URL in the browser history stack) everywhere else. You can override this behavior by specifying the type parameter....
๐ŸŒ
Glitch
support.glitch.com โ€บ coding help
Get url params and redirect to url after - Coding Help - Glitch Community Forum
July 24, 2020 - WARNING Because you are using URLs withing URLs, you might need to replace the special characters of the URL with encodeURIComponent(). More info on that here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
๐ŸŒ
Prefinery
help.prefinery.com โ€บ prefinery support center โ€บ public docs โ€บ how to pass user data as redirect url parameters on form submit
How to pass user data as redirect URL parameters on form submit - Prefinery Support Center
May 4, 2023 - prefinery_data.user.email (user's email address) and prefinery_data.user.referral_code (user's referral code) are two of the supported Prefinery variables (usable only in the following method) that allows you to access data for the user who submitted the form with your custom script as described here: How to run scripts when the Signup Form is submitted? Your script should go in Signup Form > JS tab > Conversion Tracking Code as shown below: Then in the Settings tab, you can set the form to show a thank you message though it won't really be shown since the user will just get redirected by the script anyways: