external javascript function not being called from onload/onclick events

Posted on 2007-10-06
Last Modified: 2013-11-19

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

later the same function is called from onClick events (also not working)
Question by:Lady_M
    LVL 5

    Accepted Solution

    Remove the <script> and </script> tags from .js file, I see you at least have the </script>.
    LVL 12

    Assisted Solution

    An external Js file won't require the script tags (as mentioned above).

    And is it a problem with this particular function? Or do all functions in external js file fail on trigger?

    Author Comment

    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.

    Author Comment

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

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System ( introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
    Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
    This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
    The viewer will learn how to count occurrences of each item in an array.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now