CHunky Universe of Vigourous Astonishing SHarepoint :)

Using SharePoint tooltips

I found a great post about using sharepoint tooltips on Andrey Markeev’s (@amarkeev, omlin) blog: JavaScript ToolTip’ы для SharePoint. He describes how he found the standard sharepoint tooltips and how they can be reused. The best part of it his “research”. Andrey’s conclusion is to create an own, simplified javascript class which enables “sharepoint” tooltips. I modified it somewhat. I think there is no need to instantiate a TooltipManager…

var Takana = window.Takana || {};
Takana.ToolTipManager = function () {

    var _divId = "my_tooltip";
    var _innerDivId = "my_tooltip_inner";

    function createTitleAndDescriptionHtml(title, description) {
        return String.format(

    function showTooltip(element, rawHtml) {

        var tooltipDiv = $get(_divId);
        if (tooltipDiv == null)
            tooltipDiv = createTooltip();

        $get(_innerDivId).innerHTML = rawHtml;

        displayTooltipNextToElement(tooltipDiv, element);

    function displayTooltipNextToElement(tooltipDiv, element) { = '';
        var loc = Sys.UI.DomElement.getLocation(element); = loc.x + 'px'; = loc.y + element.offsetHeight + 2 + 'px';

        if (tooltipDiv.curTimeout != null)

    function createTooltip() {
        var mainDiv = document.createElement('span') = _divId;
        mainDiv.className = 'ms-cui-tooltip'; = 'auto'; = 'absolute';

        var bodyDiv = document.createElement('div');
        bodyDiv.className = 'ms-cui-tooltip-body'; = 'auto';

        var innerDiv = document.createElement('div'); = _innerDivId;
        innerDiv.className = 'ms-cui-tooltip-glow'; = 'auto';




        return mainDiv;
    function hideDiv() {
        $get(_divId).style.display = 'none';

    var manager = {};
    manager.attachToolTip = function (element, title, description) {
        $addHandler(element, 'mouseover', function (e) { 
            showTooltip(element, createTitleAndDescriptionHtml(title, description)); 
        $addHandler(element, 'mouseout', hideDiv);

    manager.attachToolTipRaw = function (element, rawHtml) {
        $addHandler(element, 'mouseover', function (e) { 
            showTooltip(element, rawHtml); 
        $addHandler(element, 'mouseout', hideDiv);
    return manager;

Now a manager is created on a page per default. To add a tooltip, just use the TooltipManager:

Takana.ToolTipManager.attachToolTip($get('my_div'),'Help','Here comes help text!');

Actually, this has become an independent class. The only thing from SharePoint which is reused are the css classes. The outer div has to be absolute-positioned:

These are nice tooltips. The best thing with them they are automatically branded like the rest of the SharePoint.

This solution uses only the ASP.NET javascript functions for parsing, no jQuery dependency. But in most projects jQuery is used and if so rewriting it for jQuery will shrink the code. I’ll show it in an update of this post.


The code rewritten as jQuery extension for sharepoint-ish tooltips:

(function ($, undefined) {
    var sharepointTooltip = function(html) {
        var element = $(this),
            innerDiv = $("<div class='ms-cui-tooltip-glow' style='width:auto;'></div>")
            bodyDiv = $("<div class='ms-cui-tooltip-body' style='width:auto;'></div>")
            outerDiv = $("<span class='ms-cui-tooltip megler-tooltip' style='width: auto; position: absolute;'></span>")
	    showTooltip = function() {;
		  var elementOffset = element.offset(),
			elementWidth = element.width(),
			outerDivWidth = outerDiv.width(),
			leftDiff = elementOffset.left - outerDivWidth,
			showToLeft = leftDiff > 0,
			left = (showToLeft ? (leftDiff - 2) : (elementOffset.left + elementWidth + 15)) + 'px',
			top = + element.height() - outerDiv.height() + 'px';
		  outerDiv.css({ left: left, top: top });
	     hideDiv = function() {


            mouseover: showTooltip,
            mouseout: hideDiv
        sharepointTooltip: sharepointTooltip

An example of using it is:

var h = $("h1");



One response to “Using SharePoint tooltips

  1. Pingback: Using SharePoint tooltips | Share your knowledge

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

Daniel Chronlund Cloud Tech Blog

News, tips and thoughts for Microsoft cloud fans

Вула Чăвашла

VulaCV - Чăвашла вулаттаракан сайт

Discovering SharePoint

And going crazy doing it

Bram de Jager - Architect, Speaker, Author

Microsoft 365, SharePoint and Azure

SharePoint Dragons

Nikander & Margriet on SharePoint

Mai Omar Desouki

PFE @ Microsoft

Cameron Dwyer

Office 365, SharePoint, Azure, OnePlace Solutions & Life's Other Little Wonders


Me and My doings!

Share SharePoint Points !

By Mohit Vashishtha

Jimmy Janlén "Den Scrummande Konsulten"

Erfarenheter, synpunkter och raljerande om Scrum från Jimmy Janlén

Aryan Nava

DevOps, Cloud and Blockchain Consultant


SharePoint for everyone


Ryan Dennis is a SharePoint Solution Architect with a passion for SharePoint and PowerShell

SharePoint 2020

The Vision for a Future of Clarity

Aharoni in Unicode

Treacle tarts for great justice

... And All That JS

JavaScript, Web Apps and SharePoint


Mostly what I know and share about...

%d bloggers like this: