I have two javascript files in one folder.I want to pass a variable one javascript file to another.what procedure should I use?
-
2Your title says 'one page to another', and your question says 'one javascript file to another'. They're very different concepts; which do you mean?Delan Azabani– Delan Azabani2011-07-18 12:39:34 +00:00Commented 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.alex– alex2011-07-18 12:39:59 +00:00Commented 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.lakshman– lakshman2011-07-18 12:42:10 +00:00Commented Jul 18, 2011 at 12:42
-
have a look at the below: stackoverflow.com/questions/1343801/…Massimiliano Peluso– Massimiliano Peluso2011-07-18 12:45:03 +00:00Commented 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?Šime Vidas– Šime Vidas2011-07-18 12:47:42 +00:00Commented Jul 18, 2011 at 12:47
Add a comment
|
2 Answers
window.postMessage is used for cross document messages. Use those messages to share data.
Comments
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.