Lady_M
asked on
external javascript function not being called from onload/onclick events
Hi
Can anyone see why this is not working please? The function is not being called. I know the function names and file paths are correct.
Thanks
===================Externa l js file====================== =
function loadInfo (serverPage, obj){
var objID = "box";
new Ajax.Updater(objID, serverPage, {method:'get', onComplete:function(){
//change tab color
if(obj != null){
var links = $('tabs').getElementsByTag Name('A');
for (var i=0; i<links.length; i++) {
links[i].className = 'plain';
}
obj.className = 'highlighted';
}
}
}
);
return false;
}
</script>
=============HTML========= ========== ====
<head>
<script type="text/javascript" language="javascript" src="sitewide_files/protot ype.js"></ script>
<script type="text/javascript" language="javascript" src="sitewide_files/global .js"></scr ipt
</head>
<body class="red" onload="javascript:loadInf o('mypage. html', null);">
later the same function is called from onClick events (also not working)
Can anyone see why this is not working please? The function is not being called. I know the function names and file paths are correct.
Thanks
===================Externa
function loadInfo (serverPage, obj){
var objID = "box";
new Ajax.Updater(objID, serverPage, {method:'get', onComplete:function(){
//change tab color
if(obj != null){
var links = $('tabs').getElementsByTag
for (var i=0; i<links.length; i++) {
links[i].className = 'plain';
}
obj.className = 'highlighted';
}
}
}
);
return false;
}
</script>
=============HTML=========
<head>
<script type="text/javascript" language="javascript" src="sitewide_files/protot
<script type="text/javascript" language="javascript" src="sitewide_files/global
</head>
<body class="red" onload="javascript:loadInf
later the same function is called from onClick events (also not working)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
How silly of me. Yes it was as simple as removing the script tags. Thanks guys.
ASKER
Thanks for getting back.
loadInfo() is the only function I am using right now. (Apart from all the ones in prototype.js.)
It works fine if I put the function in the head of the html and use either the body onload or event.observe. But as soon as I move it into the external file (which is in the same directory as prototype) then nothing happens. The function isn't being called.
I'll remove the script tags and see if it makes a difference.