Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Calling Of Functions Between Mulitple External Javascript Files, How do I use an external script to call a function from another script
szupie
post Apr 19 2006, 10:59 PM
Post #1


S.P.A.M.S.W.A.T.
Group Icon

Group: Members
Posts: 814
Joined: 22-January 05
From: San Antonio, Texas (No, I'm not dumb. I just moved here...)
Member No.: 2,284



I have a page that requires many Javascript functions. In order to make the coding easier to read and edit, I decided to seperate them into 3 Javascript files. Two files will each do a specific job. One file will have the shared functions that both other 2 files will need to use. They are all linked to a page using three <script> tags.

The difficult part is that after the page calls a function in one of the special code files, that Javascript file will need to call the functions located in the common Javascript file. The file will call several functions, and it will an argument with it each time.
When I try to call the function as if it were on the same file, the script stops. I Googled for solutions (14 different queries and over 10 clicked results), but only a few sites had information relevant to my question. This page was the closest to helping me solve the problem. However, the page (and possibly server) no longer exists, and besides, the solution on the cached page didn't help me.
Go to the top of the page
 
+Quote Post
mastercomputers
post Apr 20 2006, 05:41 AM
Post #2


BUG.SWAT.PATROL
Group Icon

Group: Members
Posts: 626
Joined: 1-September 04
From: Auckland, New Zealand
Member No.: 27



Can you shed some code examples, usually it just depends on the order in which you load the scripts. Also if the script performs an action that requires a function, that function must be known before it's called, the only way around that is calling the action when everything is loaded, or reordering your functions.

In that example shown, it shows that the function is loaded first and then the action to calling it is in the next file, you could not do this the other way around because that function would be undefined. Whatever you are doing, it sounds like you would be best using a class.


Cheers,


MC
Go to the top of the page
 
+Quote Post
szupie
post Apr 21 2006, 12:13 AM
Post #3


S.P.A.M.S.W.A.T.
Group Icon

Group: Members
Posts: 814
Joined: 22-January 05
From: San Antonio, Texas (No, I'm not dumb. I just moved here...)
Member No.: 2,284



After I made an example site in HTML, I rewrote it again and again and found that it did not have any problems. So, I consulted my XUL file (which is actually where I have the problem) and tried to fix the perfect page to make something go wrong. However, I could not. So I tried to adapt the XUL file into an HTML file, and miraculously, the page worked. Now I know that this Javascript problem exists only in XUL. (By the way, if you still want to see my example site, it is here.)

Do you know why this happens in XUL? If you don't know, could you tell me about classes?
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Getting Screen Resolution using Javascript.(8)
  2. How To Create A Popup Window With Javascript?(19)
  3. javascript vs java(12)
  4. Javascript: Disable Mouse Right-click In Browser(16)
  5. Best Way To Learn Javascript(9)
  6. Javascript: Text To Texbox And Back To Text(2)
  7. Browser Quaker Script - Shock Your Visitors!(5)
  8. Javascript: Simple Slidedown Menu(2)
  9. JavaScript: Hide And Show Any Element With CSS(5)
  10. Ever Needs To Find Out A Table Height Or With With JavaScript(2)
  11. Create And Import JavaScript Modules For A Large Script(2)
  12. Vertical Marquee Using JavaScript(0)
  13. JavaScript Frames & Querystring(4)
  14. JavaScript Off Redirect Script(2)
  15. Enlarge Image Script(19)
  1. I Need Help With Javascript.(7)
  2. Problems With Dynamically Loading Javascript(2)
  3. One Click To Copy Script(0)
  4. Add Text To Textarea(6)
  5. Javascript Question(4)
  6. Javascript: How Do I Create Embedded Pop-up Windows?(7)
  7. Problem With Javascript Alert();(9)
  8. Include Function For Javascript(7)
  9. Fun With Javascript And Forms(2)
  10. Copy To Clipboard Function(5)
  11. Javascript Help Needed : Alert(z) Works Fine But Document.write Not(2)
  12. Javascript Changes Aren't Working.(6)
  13. Love Script(3)


 



- Lo-Fi Version Time is now: 8th September 2008 - 05:34 AM