Domanda

I have a document center with a custom master page. The page is designed with IE9/HTML5/CSS3 in mind. In my other question, I worked out how to fix the IM Presence icons by fixing some core SharePoint javascript that is defunct as of IE9. This time, I have noticed that when I click the context menus for items in a ListView web part or document library, the "Send To" submenu does not expand. This menu still works in Firefox, but people should just ideally be using IE for SharePoint for most of the functions to work properly. Has anyone else seen this, specifically? I know it must be related to the expandos issue in my other question but I have done a lot of digging and not been able to unearth the key location for the problem. It's like the javascript just stops running somewhere with little or no explanation.

Thanks,

  • Matt

Update 12/7/2012

If you look at the comments for the answer you should get good information on how and where to implement the fix.

È stato utile?

Soluzione

Comparing execution in IE and in FireFox, I've found out that the problem is that a special "submenuRoot" attribute in IE is not set on the li element, which represents the "Send To" menu node.

After some painful debugging, I've tracked the issue back to method MergeAttributes in the core.js file. This method looks like this:

function MergeAttributes(oTarget, oSource)
{ULSsa6:;
    if (browseris.nav || oTarget.mergeAttributes==null)
    {
            // ... code for non-IE browsers, skipped for clarity ...
    }
    else
    {
        oTarget.mergeAttributes(oSource);
    }
}

The oTarget.mergeAttributes(oSource); line, which is obviously the only code which executes in IE, doesn't work as expected. Given oSource.submenuRoot attribute defined and correctly set, after this call, oTarget.submenu remains undefined.

Obviously, the mergeAttributes method works differently for different content modes.

You have several options to fix this, the most obvious would be to override the MergeAttributes function from the masterpage, removing the if condition, and leaving only the first code block. I've tried this, and it works fine (I have IE 9.0.8112.16421).

The fixed code for the function is presented below:

function MergeAttributes(oTarget, oSource)
{
    var oAttributes=oSource.attributes;
    for (var i=0; i < oAttributes.length; i++)
    {
        var oAttrib=oAttributes[i];
        if (oAttrib !=null &&
            oAttrib.specified &&
            oAttrib.nodeName !="id" &&
            oAttrib.nodeName !="ID" &&
            oAttrib.nodeName !="name")
        {
            oTarget.setAttribute(oAttrib.nodeName, oAttrib.nodeValue);
        }
    }
    if (oSource.getAttribute("type") !=null)
        oTarget.setAttribute("type", oSource.getAttribute("type"));
    if (oSource.submenuRoot !=null)
        oTarget.submenuRoot=oSource.submenuRoot;
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top