Click to See Complete Forum and Search --> : having trouble passing a global variable between pages


clothor
09-24-2004, 09:40 AM
Hi gang - I'm having a very peculiar problem passing variables between 2 pages. I can successfully set and pass variables under most circumstances, but when I change how the new page gets called then it breaks. Here is the scenario:

Working examples:
* function does stuff & sets global variables
* user hits a button to go to next page (onclick=parent.location='nextpage.htm')
the next page can see everything just fine

Non Working example:
*Function does stuff
user hits button to go to next page (onclick='function()')

* within this function it sets the global variable & performs the page change with parent.location='page.htm'
* On the subsequent page I can successfully see all the variables from the working examples, but NOT the one called in the above function.

The only common denominator is how the page gets changed, so I can't figure it out. Any suggestions?

Fang
09-24-2004, 10:33 AM
How does the onclick='function()' change the page?

Warren86
09-24-2004, 11:38 AM
Clothor:
Take a look at this. Maybe it will help.

----------- Main document ---------------

<HTML>
<Head>
<Script Language=JavaScript>

var anyThing = "This_Gets_Transferred" // no spaces allowed

function nextPage(xferThis){

window.open("nextPage.html",xferThis);
}

</Script>
</Head>
<Body>
<center>
<input type=button value="Next Page" onClick="nextPage(anyThing)">
</center>
</Body>
</HTML>
----------------- NextPage.html ----------------
<HTML>
<Head>
<Script Language=JavaScript>

var somethingUseful = window.name;

</Script>
</Head>
<Body>
<Div id=isGlobal></Div>
<Script>
isGlobal.innerHTML = somethingUseful;
</Script>
</Body>
</HTML>