javascript – Window.opener alternative when not opening a new window – Education Career Blog

Small prob i’m using the following line of code

customerName = window.opener.form2.custName.value;

The problem is that I’m no longer opening the page in a new window, I’m opening it in the same window and thus replacing the older page.

Is there anyway for me to get the same information?



Pass it as a paratemer in the query string to the new page.

If you would open the new page as, say: <a href="newPage.html">..., pass the details as <a href="newPage.html?custName="+document.form2.custName.value>

As an alternative you can use cookies to store the data from page 1 before you navigate away and retrieve it in page 2.


If you aren’t opening a new window, window.opener won’t be available.

You could try passing the value of custName on the query string e.g.<yourValueHere>.

Its relatively easy to get query string values in javascript, try using for example.

Otherwise, set a cookie and retrieve its value on the 2nd page.


You need to pass the value / values you want on to the new page in some way. Some pointers:

  • Use a cookie to store the value in one page, then retrieve it in the next.
  • Pass it on as a parameter in the URL, or by submitting a form to the new page.
  • Store it in session, then retrieve it.

Of course, you may also wish to consider the nature of the data. If it is sensitive, you should use the session or form alternatives to ensure that info is not viewable from the outside (in a cookie, or in the browser’s URL, for instance).

Leave a Comment