Monday, March 24, 2008

Add Messenger Presence to Web Pages

Did you know it's extremely easy to add Messenger presence to web pages?

I recently ran across the ActiveX control "Name.NameCtrl" that you can call via client-side script and display the Messenger status icon (which also provides calendar availability, link to email, link to instant message, etc).

The control has two main methods - ShowOOUI() and HideOOUI().

The concept is simple:
1) instantiate the control on page load
2) add callable functions to Show/Hide the presence info
3) use an event such as onmouseover/onmouseout to call the functions

If you're using Microsoft's AJAX .net framework, they make it really easy providing the perfect place to instantiate the object (the built-in pageLoad() event) - and there's even a Sys.UI method for getting the X and Y coordinates of an element.

If you're not using the framework, you can still do it the old fashioned way.

For example:



// create Messenger activexobj (using pageLoad(), body onLoad, etc)
NameObj = new ActiveXObject("Name.NameCtrl");

// show Messenger icons
function ShowOOUI(name, element)
{
var offsetX = 0;
var offsetY = 0;
var parent;
// this X/Y coordinate code was taken from the AJAX .NET framework
for (parent = element; parent; parent = parent.offsetParent) {
if (parent.offsetLeft) {
offsetX += parent.offsetLeft;
}
if (parent.offsetTop) {
offsetY += parent.offsetTop;
}
}
NameObj.ShowOOUI(name, 1, offsetX, offsetY);
}

// hide Messenger icons
function HideOOUI()
{
NameObj.HideOOUI();
}

Then just call it from an element's onmouseover/onmouseout events like:
onmouseover="ShowOOUI('somebody@nowhere.com', this);"
onmouseout="HideOOUI();"

FYI - My usage has been in an intranet environment using Windows Messenger 5.1 (SIP/Live Comm Server backend). It's also my understanding that Office is what actually installs the prerequisite DLLs.

Additional info here.

3 comments:

  1. Hi,
    Thanks for great tip!
    Do you know is this functionality can be achieved for Mozilla browsers?

    Thanks again,
    Vlad

    ReplyDelete
  2. sorry vlad, i don't know of anyway to achieve this functionality in non-ie browsers :(

    ReplyDelete
  3. thanks for this helpful article!

    ReplyDelete