Forums > Javascript
> How to include or use external javascript functions or variables in another javascript file.
najeebputhiyallam
Posted on Jun 28, 2009
Join Date: March 2009
Location: India ( Bangalore )
Posts: 12
How to include or use external javascript functions or variables in another javascript file.
Hi guys i want to access a variable or function from another JavaScript File to another JavaScript File..
PS: In PHP we use INCLUDE or REQUIRE to do it.
kevin
Posted on Jun 29, 2009
Join Date: May 2008
Location: India ( chennai )
Posts: 4978
RE : How to include or use external javascript functions or variables in another javascript file.
Hi, First create one html or php file then copy and paste below code.
<script language="javascript"> var strValue = "How are you..."; </script>
Then create another file called demo.js in that file copy and paste below code alert("Hi, "+strValue);
Now include javascript in the html or php file like below <script language="javascript"> var strValue = "How are you..."; </script> <script language="javascript" src="demo.js"></script>