-5

I have two javascript files and one html page. i want to include a js file to another js file but i dont know how to include js file to another one.

anyone can please help me?

following is my code

html code:

   <html lang="en">
   <head>
   <script src="main.js" ></script>

   </head>
   <body onload="show()">
   </body> </head>
   </html>

following are the javascript files:

1.js

  var x=10;
  function show()
  {
     setvalue(x)
   }


2.js

   var D=;
   function setvalue(x)
   {
     D = x;
     alert(D);
   }
4

1 Answer 1

-1

if it's just a matter of accessing the functions and objects in the first javascript file just do something like this: <script src="main1.js"></script> <script src="main2.js"></script>

this way any function in main1.js will be available in main2.js

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.