0

I have two javascript files in one folder.I want to pass a variable one javascript file to another.what procedure should I use?

5
  • 2
    Your title says 'one page to another', and your question says 'one javascript file to another'. They're very different concepts; which do you mean? Commented Jul 18, 2011 at 12:39
  • You are including both on the one page? Please add more detail, at the moment your question is unclear. Commented Jul 18, 2011 at 12:39
  • exactly I want to send the variable one javascript file to another javascript file.they are in one folder. Commented Jul 18, 2011 at 12:42
  • have a look at the below: stackoverflow.com/questions/1343801/… Commented Jul 18, 2011 at 12:45
  • @lakashman And those JavaScript files are executed how? Are they included inside HTML pages which are loaded in a browser? Commented Jul 18, 2011 at 12:47

2 Answers 2

2

window.postMessage is used for cross document messages. Use those messages to share data.

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

Comments

0

Question is bit confusing, If the 2 javascript files are in 2 different pages you can use a query string to pass the values.

If both of them are in a single page the value can be simply passed using a variable. Simply define the variable int he first called script file or in the page. It can be accessed from any other javascript in the page defined below the first script.

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.