I was questioned regarding Lync 2010, why does it always open the chat window hyperlinks in the same IE tab. The IE tabs settings doesn’t seem to take effect. No matter whether you set it to “A new window”, “A new tab in the current window” or “The current tab or window”, clicking a hyperlink again will replace the original tab’s content with the new one.

 

 

Sometimes this is not the expected behavior. If I send 2 shopping items to my friend via the chat window, usually I want him to compare them in 2 windows after he clicks the 2 hyperlinks.

 

Actually this is a common issue, not only to Lync 2010, but also to legacy Office and Live messenger versions. Also it is interesting, I was also told that, 3rd party browsers don’t have this issue. The hyperlinks are always opened in new tabs/windows, as long as they are set to Windows’ default browser.

 

The secret behind is that Lync 2010’s chat window uses mshtml.dll to present the hyperlinks. What you see in the chat window’s content area is actually an HTML page. The hyperlinks are <a> tags.

 

 

In other words, Lync puts <a> tags in the mshtml.dll area, mshtml.dll is responsible to render the tags as hyperlinks and handle click events. As you may know that IE uses mshtml.dll too to render web pages, so you can think both the source chat window and the target IE tab are actually mshtml.dll internal. The magic is,

 

mshtml.dll in the chat window handles the click event as a COM activation to the target IE tab, through the INavigate2 COM interface.

 

It is similar as you click a hyperlink inside an IE Window. <a> tags in IE are always opened by the same window, while <a> tags in the chat window should be always opened by the same target IE tab/window too. If Lync puts a <a> tag with attribute target=”_blank” in the mshtml.dll area, there should be a new tab for each click then.

 

Below is part of the call stack in Lync, after you click a hyperlink in the chat window

 

mshtml!CDoc::FindTargetWindow

mshtml!CDoc::DoNavigate+0x53d

mshtml!CAnchorElement::ClickAction+0x10

mshtml!CElement::DoClick+0x156

 

When the Windows default browser is not IE, mshtml.dll is able to detect this and opens the hyperlink via the ShellExecute API call. This API follows the tab/window configuration in the above IE dialog box.

 

It gets more complex on Windows Vista and later when UAC is enabled. You will found the hyperlinks are opened in the same tab or a new tab “randomly”. Due to the new broker architecture in IE protect mode, function CDOC::FindTargetWindow might not be able to find the original tab, depending on the security zones of the hyperlinks/integrity levels of the tab processes. Mshtml.dll will open another tab for a new click, if it is not able to activate the navigation in the original tab/window.

 

Lync 2013 has a new design that replaces mshtml.dll. It now opens the hyperlinks by calling ShellExecute, which follows the IE tab/window configuration to open the hyperlinks in new tabs by default.

 

Best Regards,

Jun Tao from APGC DSI Team