I'm currently writing a Firefox extension that allows the user to highlight a phone number and then call it using a button from the context menu. At the moment the context menu just says "Call Number" but I'd like it to say "Call '0xxxxxxxxxx'" ie whatever the number highlighted is. To do this I need an event that goes off whenever text is highlighted.
I've tried to add a mouseup event using both of these methods:
Window.addEventListener("mouseup", test(), true);
var overlay = getElementById("aca-button-overlay");
overlay.addEventListener('mouseup', test(), true);
But neither of these worked.
Change the label by setting a listener for "onpopupshowing" in your XUL code. For example:
<script>
function insertPhone() {
var pitem = document.getElementById("phoneNumber");
pitem.label = "Call " + phoneNum;
}
</script>
<menupopup id="mymenu" onpopupshowing="insertPhone()">
<menuitem id="phoneNumber" label="Call" />
</menupopup>
See the following for more detail:
https://developer.mozilla.org/en-US/docs/XUL/PopupGuide/ContextMenus
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.