views:

148

answers:

1

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 :)

+1  A: 

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.

Brock Adams
Would I add a listener to each button (each row - around 300)
Jigs
@Jigs: Yes. It would be easy to to do as you are adding the links. Post your code and we can show you exactly how.
Brock Adams