Hello friends, I m creating a toolbar for Firefox browser which contains some buttons on it. and i have written event handlers for these button click events into a .JS file. When user will open a our web site in browser and when i we see source code for this web page then we find that it has included with another .js file which contains many functions. for example this Js file looks like: <script language="javascript" src="Javascripts/ToolBar.js"></script> Now i want to call these functions from my toolbar .JS file. How can i call it. If i call directly to that function then it gives error to me that function is not defined . PLz help me thanks in advance..... Harish dixit.
That's not the way to include a JS file in another JS file. Insead, try a function like the following: function include_dom(script_filename) { var html_doc = document.getElementsByTagName('head').item(0); var js = document.createElement('script'); js.setAttribute('language', 'javascript'); js.setAttribute('type', 'text/javascript'); js.setAttribute('src', script_filename); html_doc.appendChild(js); return false; } Code (markup): And use in the other JS file like this: include_dom( "Javascripts/ToolBar.js" ); Code (markup): More info here.
Well, maybe I was wrong when I didn't put it LOUD and CLEAR that the full URL is required ... include_dom( "http://www.your-site.com/Javascripts/ToolBar.js" ); Code (markup): This solution is definitely DOM-compliant BTW