OCS presence in SharePoint AJAX-based web part
I'm currently implementing AJAX-based web part which displays search result. This search result has user names and opposite to each name I'm rendering the OCS presence indicator. This indicator works fine in IE6 but I can't get it to work in IE7/8.
Basically the problem in IE7/8 is that OCS is rendered but when you mouse over it nothing is shown. If you try to scroll page down then mouse over the OCS icon you will see the OCS actions menu in the bottom of the page instead of seeing it on the opposite to the user name.
My AJAX-based web part uses jQuery post method to make a request to the server and receives json which is then rendered to the div.
My HTML for the user name looks like this:
<nobr>
<span>开发者_如何学JAVA
<a target='_blank' href='/ViewExpert.aspx?uid=4'>Some Expert</a>
<img height='1' width='3' border='0' alt='' src='/_layouts/images/blank.gif'><a class='ms-imnlink'
onclick='IMNImageOnClick();return false;' href='javascript:'>
<img height='12' width='12' border='0' id='3' ShowOfflinePawn='1' type='smtp' sip='sip@sip.com'
src='/_layouts/images/blank.gif' valign='middle' name='imnmark' alt='No presence information' title=''>
</a>
</span>
</nobr>
After the HTML above is rendered on the page I call the following two lines of code:
//have to reset this value, otherwise ProcessImn() fails after next AJAX request
imnCount = 0;
ProcessImn();
Any ideas why it doesn't work in IE7/8?
I'm sure that the misplaced presence controls are caused by the buggy init.js in SharePoint 2007. The init.js does not account for scrolling. Since you shouldn't touch files that are out-of-the-box and break support, you might want to hack your own JavaScript that sets up the ActiveX NameControl for presence. I can't take credit for the fix. I found it by Googling. Unfortunately, I cannot recall where I read about it.
If you must hack SharePoint 2007's init.js, you might want to try this:
In function IMNShowOOUI(inputType),
I would change the lines from:
oouiX=objRet.oouiX;
oouiY=objRet.oouiY;
to the following:
oouiX = (objRet.oouiX - document.body.parentNode.scrollLeft;
oouiY = (objRet.oouiY - document.body.parentNode.scrollTop;
Rather than init.js, you might want to try hacking the JavaScript that comes with the MS example "Presence in Web Applications" Beware that you'll have to apply the same fix for the scrolling issue.
Good luck:)
精彩评论