I want to use global variable in .js files. For example,
when I read a file content in \" a.js + a.html \" and saved into a certain variable \'fileContent\'
Given that the architecture for Windows 8 Applications is the single page model, where you don't navigate the browser, but merely load a fragment of HTML and insert it into the current document, this is very easy. I would, however, recommend using some typing, rather than just a "naked" global variable.
File A (globals.js):
WinJS.Namespace.define("MyGlobals", {
variableA: null,
});
Include this at the top of default.html after the WinJS includes.
File B (b.js):
// your other code
...
MyGlobals.variableA = getValueFromSomewhere();
File C (b.html, or c.js):
// your other code
...
printSomethingAwesomeFromData(MyGlobals.variableA);