Jigs
Jigs

Reputation: 401

Calling a greasemonkey function on a user clicking a button

I have written a script that adds an additional column and a link in each row. The problem is I wan the links to call a function in my greasemonkey script and pass a variable to it.

I have read that due to the nature of greasemonkey being in a sandbox its not possible without a function called 'unsafeWindow'. I can't for the life of me figure out how and a lot of the information seems to be out of date.

Please someone put me out of my misery :)

Upvotes: 1

Views: 2056

Answers (1)

Brock Adams
Brock Adams

Reputation: 93443

The exact approach depends on details that are not in the question. You might need to post the code and exactly what variable you want passed.

But, in general, you could do something like this:

NewlyAddedLink.addEventListener ("click", function() {YourFunc (SomeGlobalVariable);}, false);

You don't necessarily have to worry about unsafeWindow.

Upvotes: 1

Related Questions