The cleanest way to pass a variable is to send it as part of the URL.
for example, your link would be:
<a href="#" onclick="describe('Stop Sign');">Stop Sign</a>
your javascript on the main page would be:
function describe(term) {
window.open("windowpage.html?"+term,"newWin","widt h=100,height=100")
}
(essentially the URL of the window that pops open would be
"windowpage.html?Stop%20Sign")
The scripting in that window, looks for the term after the '?' in the
URL like this:
var term = location.href.substring(location.href.indexOf("?") +1);
// essentially everything the "?"
then look up the term in your array.
By the way, your definitions arrays would probably work out better if
they were like this instead:
DefinitionArray = new Array();
DefinitionArray["Stop Sign"] = "Stop Sign: A red sign with the word
STOP.";
DefinitionArray["Yield Sign"] = "Yield Sign: A yellow sign with the
word YIELD.";
DefinitionArray["Go Sign"] = "Go Sign: A green sign with the word GO.";
DefinitionArray["Right Turn Sign"] = "Right Turn Sign: A white sign
with an arrow pointing RIGHT.";
That way you can then use:
document.write(DefinitionArray[term]);
|