473,804 Members | 2,536 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

calling functions in other javascripts

31 New Member
Hi,

Is there any way to call function in another javascript , as in Object Oriented languages ?

Anushka
Mar 28 '08 #1
3 1092
lopez
6 New Member
hi there,
use the below code
Expand|Select|Wrap|Line Numbers
  1. <script language="javascript">
  2. function call()
  3. {
  4. call2();
  5. }
  6. function call2()
  7. {
  8. alert("call2 was called");
  9. }
  10. <script>
  11.  
Now do something and call "call()". ur "call2()" will be called by itself........
regards
lopez.
Mar 28 '08 #2
anudu
31 New Member
hi there,
use the below code
<script language="javas cript">
function call()
{
call2();
}
function call2()
{
alert("call2 was called");
}
<script>

Now do something and call "call()". ur "call2()" will be called by itself........
regards
lopez.
thanks lopez.

but my problem is, acording to your example if call2() is written in another .js file can I access it within call() method? as we do in OO languages, we create an object from the class and access its method. actually i am dealing with two .js files. i want to access a function in one .js file from another .js file.
Mar 28 '08 #3
vee10
141 New Member
Hi,

yes u can do this

i will give u simple example

Expand|Select|Wrap|Line Numbers
  1. sampleA.js
  2. function CallmethodA()
  3. {
  4. //some logic 
  5. }
  6. sampleB.js //this will call sampleA.js methods
  7. function CallMethodB()
  8. {
  9. //some logic
  10. CallmethodA()
  11. }
  12.  
  13. <html>
  14. <head>
  15. <script type="text/javascript" src="sampleA.js"></script>
  16.     <script type="text/javascript" src="sampleB.js"></script>
  17.     <script type="text/javascript">
  18.  
  19.     function checking()
  20.     {
  21.     call1();
  22.     }
  23.  
  24.  
  25.     </script>
  26. </head>
  27. <body onload="checking()">
  28. </body>
  29. </html>
  30.  
or u can check out this link
[EDIT]

thanks lopez.

but my problem is, acording to your example if call2() is written in another .js file can I access it within call() method? as we do in OO languages, we create an object from the class and access its method. actually i am dealing with two .js files. i want to access a function in one .js file from another .js file.
Mar 28 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
4522
by: Julia Briggs | last post by:
Hello World - I admit I'm new to javascript but I've tried for days to find a solution to my problem. Basically I have 3 unique javascript files that do different screen display events that I want to dynamically call, where the current page would then refresh after a user clicks on any one of three associated button links. Could someone please assist me and craft a simple script that would accomplish this feat of impossibility? ...
4
4073
by: Smoke | last post by:
We had a javascript calling a Cold Fusion page (.cfm) and it was working for 2 years. Suddenly yesterday or today its decided it doesn't want to work anymore. I'm picking up somebody elses code I don't know all of the rules here. All of the examples I've found really want .JS files if called with a script tag, example below. <script src="http://www.website.com/javascripts/xxx.js"> </script>
7
1650
by: JCO | last post by:
I have several JavaScripts in a web page. Each script is in an individual file with extension .js. I want to know if it is possible to put all functions in one single page. If so, how do I call the specific script that I want to run. This is how I call an individual script: <SCRIPT LANGUAGE="JavaScript" src="valForm.js"></SCRIPT> Where valForm is a script that looks like this: function valForm()
8
4691
by: Jakej | last post by:
I've been using a javascript in an html file for a banner slider, and it works as desired. But I'd like to use it on more than one page and it would be great if I could transfer the code to a .js file and call it with the <script src="filename.js"></script> tags as I do for many other .js files. But, when I try to do that way, it doesn't work right. It will display the banner text, but only on the 0,0 page coordinate and doesn't slide....
19
4268
by: Ross A. Finlayson | last post by:
Hi, I hope you can help me understand the varargs facility. Say I am programming in ISO C including stdarg.h and I declare a function as so: void log_printf(const char* logfilename, const char* formatter, ...); Then, I want to call it as so:
5
2236
by: Dave | last post by:
does calling a regular function cost any cpu time? In other words, is it faster to write the code of two functions into main(), or is it the exact same thing as calling two functions. I know its nitty gritty but its necessary for my program. thanks dave
2
2818
by: Daniel Lidström | last post by:
I'm using a library called fyba. This library reads and writes files in a format called sosi. fyba uses the following code to determine if the calling process has own methods to handle errors, messages, etc: // If this parameter is NULL, // GetModuleHandle returns a handle of the file used // to create the calling process. hInstExe = GetModuleHandle( NULL ); if( hInstExe!=NULL )
18
4365
by: John Friedland | last post by:
My problem: I need to call (from C code) an arbitrary C library function, but I don't know until runtime what the function name is, how many parameters are required, and what the parameters are. I can use dlopen/whatever to convert the function name into a pointer to that function, but actually calling it, with the right number of parameters, isn't easy. As far as I can see, there are only two solutions: 1) This one is portable. If...
4
4803
by: Edwin Gomez | last post by:
I'm a C# developer and I'm new to Python. I would like to know if the concept of Asynchronous call-backs exists in Python. Basically what I mean is that I dispatch a thread and when the thread completes it invokes a method from the calling thread. Sort event driven concept with threads. Thanks. Ed Gomez
1
1674
by: susmitha | last post by:
hai iam a fresher in .net.My problem is I have one javascript sourcefile and some javascript functions in my aspx page like shown below. <script language=javascript src="javascripts/popcalendar.js" type="text/javascript"/> <script language="javascript" type="text/javascript"> function callpopup(v1,v2,v3,v4) { var txtName =document.getElementById(v1).value; var txtSal = document.getElementById(v2).value; ...
0
9591
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10343
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10087
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7631
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5529
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4306
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.