PDA

View Full Version : accessing external variables in a jscript



kingman
02-25-2004, 09:53 PM
I have an external script.
On my web page I try to call it this way:


<script type='text/javascript' src="http://www.bizmox-systems.com/mhra/icon.js" >
followed by this function:


function toggle_dynmenu(id) {
if (GetElementById(id + '_sub')) {
var dom = GetElementById(id + '_sub').style.display;
if (dom == 'none') {
GetElementById(id + '_sub').style.display = 'inline';
GetElementById(id + '_sign').src = 'mhra/minus.gif';
GetElementById(id + '_folder').src = 'mhra/tree_open.gif';
} else if (dom == 'inline') {
GetElementById(id + '_sub').style.display = 'none';
GetElementById(id + '_sign').src = 'mhra/plus.gif';
GetElementById(id + '_folder').src = 'mhra/tree_close.gif';
}
}
}
</script>

then there is some html code icluding;

mhra/minus.gif ('javascript:toggle_dynmenu("Internet");')

and then the following:



<script type='text/javascript'>
toggle_dynmenu('Internet');
toggle_dynmenu('forum');
toggle_dynmenu('macro');
toggle_dynmenu('perl');
</script>

I am trying to call the toggle_dynmenu function at the top which uses functions and variables in an external script. Is this possible?