Link to home
Start Free TrialLog in
Avatar of Lady_M
Lady_MFlag for United Kingdom of Great Britain and Northern Ireland

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
===================External 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').getElementsByTagName('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/prototype.js"></script>
<script type="text/javascript" language="javascript" src="sitewide_files/global.js"></script
</head>
<body class="red" onload="javascript:loadInfo('mypage.html', null);">

later the same function is called from onClick events (also not working)
ASKER CERTIFIED SOLUTION
Avatar of frin
frin
Flag of Slovenia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Lady_M

ASKER

Hi
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.
Avatar of Lady_M

ASKER

How silly of me.  Yes it was as simple as removing the script tags.  Thanks guys.