KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm noob with JavaScript and Greasemonkey and I'd like to write a simple script. I know that Greasemonkey wraps your code with an anonymous function so your variables won't exist after leaving the current page. However, I need a global variable. I tried to use the unsafeWindow and window objects something like this: if (window.myVar == undefined) { window.myVar = "myVar"; } If I refresh the page the condition's value is always true. Is there a way to use global variables with Greasemonkey?
Tags (comma-separated)
Save Edits
Cancel