Components.utils.exportFunction(hideListing, unsafeWindow, { defineAs: "hideListing" });
Attach the functions via addEventListener to the button element
when you create it. If you define the function above the function
you create the button in, it should work fine. It looks something
like this:
// ==UserScript==
// @name Button click demo
// @version 1
// @author LWChris
// @include https://www.w3schools.com/jsref/met_element_addeventlistener.asp
// @grant none
// ==/UserScript==
function theButtonWasClicked() {
alert("Hello World!");
}
function addTheButton() {
var btn = document.createElement("button");
var content = document.createTextNode("Say hello");
btn.appendChild(content);
btn.addEventListener("click", theButtonWasClicked);
document.getElementById("main").appendChild(btn);
}
addTheButton();
Chris
--
You received this message because you are subscribed to the Google Groups "greasemonkey-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to greasemonkey-us...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/greasemonkey-users/b89d537d-827e-43f1-ae4d-01fc52c8c29c%40googlegroups.com.