?
Solved

external javascript function not being called from onload/onclick events

Posted on 2007-10-06
4
Medium Priority
?
5,079 Views
Last Modified: 2013-11-19
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)
0
Comment
Question by:Lady_M
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
frin earned 1000 total points
ID: 20027216
Remove the <script> and </script> tags from .js file, I see you at least have the </script>.
0
 
LVL 12

Assisted Solution

by:lexxwern
lexxwern earned 1000 total points
ID: 20027275
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?
0
 

Author Comment

by:Lady_M
ID: 20027281
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.
0
 

Author Comment

by:Lady_M
ID: 20027288
How silly of me.  Yes it was as simple as removing the script tags.  Thanks guys.  
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

840 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