Please offer advice regarding the use of global parameters or alternative method(s) in the following javascript&html. The parameters passed in an onclick call are behaving as values of local variables rather than as intended values of the global variables. Thanks in advance for any suggestions.
1. onclick with parameters calls global function page with parameters
[I]<!– page content –>
<div class=”content img”><ul class=”none”>
<li><img alt=”1394-80,95,18,93″ title=”1394-80,95,18,93″ height=”200px” width=”200px” src=”[B]onclick=”page(‘1394′,’80’)”
<li>1394-80,95,18,93</li></ul></div>
2. Alert shows global variables stylenum and colornum with parameters (‘1394′,’80’) passed in call and3. page.html opens pausing at window.onload = winonload; with alert showing stylenum and colornum with null values. My expectation was that the variables would have the values (‘1394′,’80’).
external .js file containing global functions and parameters:
[I]/*— launch detail page from onclick —
var stylenum = “”;
var colornum = “”;
var page = function(stylenum,colornum)
{
alert(stylenum + ” and ” + colornum);
window.location.assign(“http://…page.html”);
}
var winonload =function()
{
window.onload = alert(stylenum + ” and ” + colornum);
anotherfunction = function(stylenum, colornum){…};
}
page.html
[I]<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“
<html xmlns=”
<head profile=”
<title>The Little Dane, Inc. annotated images of throws</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″/>
<meta http-equiv=”Content-Script-Type” content=”application/javascript”>
<meta http-equiv=”Content-Style-Type” content=”text/css”>
<link rel=”stylesheet” type=”text/css” href=”mainstylesheet.css” />
<script src=”pipesaccess.js” type=”text/javascript”></script>
<script type=”text/javascript”>
[B]window.onload = winonload;
</script>
</head>
<body>
<!– page header –>
<div class=”headerbox leftheaderbox”>
<img alt=”…” title=”…” src=”…” align=”left” hspace=”2″ /></div>
<!– page content –>
</body>
</html>