In Sharepoint 2010 and 2013, there are some existing functions to deal with the ribbon.
Below an example of what we can do:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | // we need the file "sp.ribbon.js" SP.SOD.executeOrDelayUntilScriptLoaded( function () { // use PageManager var pm = SP.Ribbon.PageManager.get_instance(); // define a function to call when the ribbon is loaded var DoSomethingWithRibbon= function (ribbon) { // For example, we can select the "Browse" tab ribbon.selectTabById( "Ribbon.ListForm.Display" , true ); // Note: You can explore the DOM to find the related IDs // other example "Edit" tab is "Ribbon.ListForm.Edit" // We can now remove the "Edit" tab ribbon.removeChild( "Ribbon.ListForm.Edit" ); } // perform an action when the ribbon has been inited pm.add_ribbonInited( function () { DoSomethingWithRibbon(pm.get_ribbon()) }); // if the ribbon is already loaded var ribbon = null ; try { // get an instance of the ribbon ribbon = pm.get_ribbon(); } catch (e) {} if (!ribbon) { if ( typeof (_ribbonStartInit) == "function" ) _ribbonStartInit(_ribbon.initialTabId, false , null ); } else { DoSomethingWithRibbon(ribbon); } }, "sp.ribbon.js" ); |
And there are also solutions to add stuff to the ribbon. I have to dig into these solutions… In the meantime you can try this blog post, or this one.