I currently have this global variable declared in javascript.js which I've imported to my main document.
var globalURL = "test URL";
When I try an alert within the javascript.js file it successfully outputs the value of globalURL.
However when I try to an alert with my current document but calling globalURL I get an error
Uncaught ReferenceError: globalURL is not defined
I'm I doing something wrong here? I followed the example here but still it doesn't work for me. Can I access variables from another file?
UPDATE: I have included my javascript.js file with my current document, so I don't think the error is there. Otherwise the first alert function within the javascript.js wouldn't have run at all.
globalURLis declared first there shouldn't be any problems. You could also remove thevarkeyword which makes the variable global regardless of where it's declared (but it still needs to be declared before use obviously).document.onready()?