Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I do not understand how to retrieve the value of a variable in a global variable JS.
Help me please.
Qv.AddExtension('Test', function () {
var var1;
var doc = Qv.GetCurrentDocument();
doc.GetAllVariables(function (vars) {
for (var i = 0; i < vars.length; i++) {
if (vars.name === "var1") {
var1 = vars.value;
break;
};
}
});
alert(var1); \\undefined
It looks like doc.GetAllVariables is an async function. That means, that your alert(var1) is executed before doc.GetAllVariables() has finished. You need to wait for that function to be finished. Please take a look at Javascript Promises.