Dynamically add tooltips? - Mozilla

This is a discussion on Dynamically add tooltips? - Mozilla ; Hi, I have an object that attaches an element on the the browser window. There can be any number of these attached. I would like a tooltip for this element, which will have content that is more rich than "tooltiptext" ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: Dynamically add tooltips?

  1. Dynamically add tooltips?

    Hi,

    I have an object that attaches an element on the the browser window.
    There can be any number of these attached. I would like a tooltip for
    this element, which will have content that is more rich than
    "tooltiptext" would allow. The content of the tooltip will need to be
    specific to the element (that is if 3 elements are attached, each will
    have unique content in its tooltip).

    What is the best way of doing this?

    Thanks,

  2. Re: Dynamically add tooltips?

    var tooltip = document.createElementNS(XUL_NS, "tooltip");
    tooltip.setAttribute("id", "mytooltip");
    var label = document.createElementNS(XUL_NS, "label");
    label.setAttribute("image", "http://.....gif");
    label.setAttribute("value", "Hello!");
    tooltip.appendChild(label);

    var element = ... // Your element.
    element.setAttribute("tooltip", "mytooltip");





    On May 9, 10:53 am, T wrote:
    > Hi,
    >
    > I have an object that attaches an element on the the browser window.
    > There can be any number of these attached. I would like a tooltip for
    > this element, which will have content that is more rich than
    > "tooltiptext" would allow. The content of the tooltip will need to be
    > specific to the element (that is if 3 elements are attached, each will
    > have unique content in its tooltip).
    >
    > What is the best way of doing this?
    >
    > Thanks,


  3. Re: Dynamically add tooltips?

    T wrote:

    >I would like a tooltip for this element, which will have content that is more rich than "tooltiptext" would allow.
    >

    You can create your own element. Its id should match the
    tooltip attribute of the element to which you're attaching the custom
    tooltip, or you can add it as a child of the custom element and set
    tooltip="_child". You can then give the tooltip arbitrary content (well,
    don't get carried away, an iframe might not work too well!)

    --
    Warning: May contain traces of nuts.

  4. Re: Dynamically add tooltips?

    Thanks!

    I finally got what I wanted working and finished the extension I was
    working on.
    ( https://addons.mozilla.org/en-US/firefox/addon/7475 )

    What I was missing was to append the dynamically created tooltip
    element to document.getElementsByTagName[0]

+ Reply to Thread