Home > Mobile >  How to redirect to an html page with parameters?
How to redirect to an html page with parameters?

Time:03-11

I have two HTML pages running on a localhost server and would like for the first page to redirect to the other one but with parameters so that I can use queries on the second page. This is my code in javascript:

var number = 5;
window.location.href = "page2.html/?numberID=number";

So that the new page will have the URL: localhost/page2.html/?numerID=5, but code just gives me a 404 page not found error, how do I fix this?

CodePudding user response:

You need to remove the slash between the page name and the question mark, otherwise the web server will think you are requesting a folder named /page2.html/, hence you are getting 404 - not found

localhost/page2.html?numberID=5

CodePudding user response:

var number = 5;
window.location.href = "page2.html?number=" number;
  • Related