Can I pass an array as a parameter to a page using window.open?

  • Add to the URL parameter the contents of your array. If the array is of reasonable size and does not have any complex structure, it will work - DreamChild
  • Actually this is the question of what kind of entry should be in the urle. I know that the exact value can be transferred using the "=" sign, but with an array of how? - Oleg Stepanov
  • window.open('index.php?x[1]=1&x[2]=2'); or window.open('index.php?x[]=1&x[]=2'); - Serge Seredenko
  • But if the page is on your own domain, then look towards localStorage. - Serge Seredenko
  • ... but, of course, the loaded page should be able to process parameters from the URL. - VisioN

2 answers 2

JSON can be used. Using JSON.stringify, generate JSON, use JSON.parse to restore an object or array. Through window.location.href and decodeURI, you can get a request with JSON. But we must remember that some browsers may have a limit on the length of the url.

    I was offered to use session storage. I think it will be much better. And already on the opening page I will parse storage. Thank you all for the help.