0

I have a question regarding window.open(). I need to open a new URL in same window, while passing some data from the previous window (different URL) .

I have code which is passing data to other window but it is opening new window.

Any suggestion how to open it in same along with data?

window.open(url,PREFIX + JSON.stringify({"some":"somevalue"));
jdlm
  • 6,327
  • 5
  • 29
  • 49

2 Answers2

1

Pass _self in your method

window.open(url,PREFIX + JSON.stringify({"some":"somevalue"), "_self");
Gabriel Diez
  • 1,648
  • 2
  • 17
  • 26
0

Use location object for directing the same window to open another url.

window.location.replace(url + PREFIX + encodeURIComponent(JSON.stringify({"some":"somevalue"})));

OR

window.location.href = url + PREFIX + encodeURIComponent(JSON.stringify({"some":"somevalue"})};

If you don't want to expose the data in the url, you have to send a reference to the data and the target website should find data via the reference.

Charlie
  • 22,886
  • 11
  • 59
  • 90