I have one variable in .aspx
code and i want to use it in my .js
code.
How to make this work?
In .aspx code..
var url = document.referrer;
var res = url.split("?");
var str = res[1];
So I want the str to be used in my .js code..
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.
Sign up to join this communityI have one variable in .aspx
code and i want to use it in my .js
code.
How to make this work?
In .aspx code..
var url = document.referrer;
var res = url.split("?");
var str = res[1];
So I want the str to be used in my .js code..
That code is not ASPX code. It is JavaScript code (inside a Script block in your ASPX file?)
If it is not a Global variable yet, you can declare it as window.js=res[1]
to force it in the global scope (and thus available to all other functions)
Time to read about Javascript Variables, Closures etc. :