[Greasemonkey] Calling a function in GM from injected HTML

IndaUK indauk at gmail.com
Fri Aug 4 15:18:26 EDT 2006


Thanks again but one problem leads to another...


I have injected many elements into the webpage, each with a different ID.

  e.g. "<span id='group_" + foo[i] + "'>[-]</span>"

I later add the event listeners by:

  var a = document.getElementById("group_" + foo[i]);
  a.addEventListener("click", RemoveGroup, true);

 

I need to pass a string (or the element ID or the element object) to my
original function.

"a.addEventListener('click', RemoveGroup, true);" seems to pass an object to
my function but I don't know what to do with it.

function RemoveGroup(sGroupName)
{
  alert(sGroupName)        //returns
"[object XPCNativeWrapper [object MouseEvent]]"
  alert(typeof(sGroupName))    //returns
"object"
}


The docs on XPCNativeWrapper confuse me. How can I reference the element
that was clicked?

Any ideas?
-- 
View this message in context: http://www.nabble.com/Calling-a-function-in-GM-from-injected-HTML-tf2052532.html#a5657879
Sent from the MozDev - greasemonkey forum at Nabble.com.


More information about the Greasemonkey mailing list