How can I call the variables that I stored in one javascript file from another?
var.js
var VAR = new Object;
VAR.myvalue = "Yeah!";
then I want to use VAR.myvalue here
sample.js
alert(VAR.myvalue);
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
First, instead of
Opt for
But so long as
var.jsis referenced first, before sample.js, what you have should work fine.var.js will declare, and initialize VAR, which will be read from the script declared in sample.js