Showing Tooltips in XUL Browser.

Keep the following code in the respective files.

.xul File

<browser id = “browser1″

type=”content-primary”

name=”content-primary”

src=”file:///Users/praveen/Desktop/Tooltip.html”

tooltip=”aHTMLTooltip”

flex=”1″ />

<tooltip id=”aHTMLTooltip” onpopupshowing=”return FillInHTMLTooltip(document.tooltipNode);”/>

.js File
function FillInHTMLTooltip(tipElement)
{

var retVal = false;
if (tipElement.namespaceURI == “http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul&#8221;)
return retVal;

const XLinkNS = “http://www.w3.org/1999/xlink&#8221;;

var titleText = null;
var XLinkTitleText = null;

while (!titleText && !XLinkTitleText && tipElement) {
if (tipElement.nodeType == Node.ELEMENT_NODE) {
titleText = tipElement.getAttribute(“title”);
XLinkTitleText = tipElement.getAttributeNS(XLinkNS, “title”);
}
tipElement = tipElement.parentNode;
}

var texts = [titleText, XLinkTitleText];
var tipNode = document.getElementById(“aHTMLTooltip”);

for (var i = 0; i < texts.length; ++i) {
var t = texts[i];
if (t && t.search(/\S/) >= 0) {
tipNode.setAttribute(“label”, t);
retVal = true;
}
}

return retVal;
}

technorati tags:, , , ,

Blogged with Flock

Advertisements
Posted in MOzilla. 1 Comment »

One Response to “Showing Tooltips in XUL Browser.”

  1. dvuckovic Says:

    thank you!

    think about going with some tag around your code, because all quotation marks are converted in respective unicode chars, and are causing bugs in xml parser if copy&pasted... but the code works, that's for sure :)


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: