When the onclick function is executed, the scope is "window", but you have
declared myVar inside your onload function. So you can do it either:
myLayer.setHTML('<a href="javascript:void(0)" onclick="myFunction(' + myVar
+ ');">Click</a>');
or then by declaring the variable to be property of the window object. I.e
inside the onload function:
myVar = "stuff";
The difference between the two is obviously when the variable gets
evaluated.
--
Tuomas
> I can't get something that seems like it should be simple to work:
>
> If I declare a variable in the onLoad function
> var myVar = "stuff"
>
> and later try to use that variable within setHTML (still within the onLoad
> function):
>
> myLayer.setHTML('<a href="javascript:void(0)"
> onclick="myFunction(myVar);">Click</a>')
>
> the variable is not passed. Any help on how to fix this would
> greatly simplify
> my life, so many thanks.
>
> Arijit
> ---
> Protein Media, Inc.
> tel: 202.462.4700 [EMAIL PROTECTED]
> fax: 202.318.1176 http://www.proteinmedia.com
>
>
>
> _______________________________________________
> Dynapi-Help mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/dynapi-help
_______________________________________________
Dynapi-Help mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dynapi-help