I have a sharepoint online custom list that when I click New Item I want it to default to browse ribbon on top instead of edit. (pretty much don't want all those details there because of what it is used for). I have done some research but none of the answers seemed to answer my question. Thanks.
Here is a screenshot on what I'm talking about:
2 Answers
- Edit your new form page.
- Add script editor.
- Click on Edit Snippet .
Add the following script
<script type="text/javascript">// <![CDATA[
function ResetRibbon() {
try {
var ribbon = SP.Ribbon.PageManager.get_instance().get_ribbon();
SelectRibbonTab("Ribbon.Read", true);
ribbon.removeChild('Ribbon.ListForm.Display');
ribbon.removeChild('Ribbon.ListForm.Edit');
} catch (e)
{ }
}
SP.SOD.executeOrDelayUntilScriptLoaded(function () {
try
{
var pm = SP.Ribbon.PageManager.get_instance();
pm.add_ribbonInited(function () {
ResetRibbon();
});
var ribbon = null;
try {
ribbon = pm.get_ribbon();
}
catch (e) { }
if (!ribbon) {
if (typeof (_ribbonStartInit) == "function")
_ribbonStartInit(_ribbon.initialTabId, false, null);
}
else {
ResetRibbon();
}
},
"sp.ribbon.js");
}catch(e)
{}
// ]]></script>
<script type="text/javascript">
function ResetRibbon() {
try {
var ribbon = SP.Ribbon.PageManager.get_instance().get_ribbon();
SelectRibbonTab("Ribbon.Read", true);
ribbon.removeChild("Ribbon.ListForm.Display");
ribbon.removeChild("Ribbon.ListForm.Edit");
} catch (e)
{ }
}
SP.SOD.executeOrDelayUntilScriptLoaded(function () {
try {
var pm = SP.Ribbon.PageManager.get_instance();
pm.add_ribbonInited(function () {
ResetRibbon();
});
var ribbon = null;
try {
ribbon = pm.get_ribbon();
}
catch (e) { }
if (!ribbon) {
if (typeof (_ribbonStartInit) == "function")
_ribbonStartInit(_ribbon.initialTabId, false, null);
}
else {
ResetRibbon();
}
} catch (e)
{ }
}, "sp.ribbon.js");
</script>
- Press Ok .
- Click on Stop Page Editing from the above ribbon / Save your page.
- try to add new item , that should be working with default browse Tab.
[Output]
Code ref : select specific tabs in SharePoint Ribbon
-
I do not have the ability to edit the NewForm page like this as we do not have the sharepoint desktop application. Only Designer and the online version. Is there another way? Oct 4, 2016 at 13:53
-
-
@EricBraun let's continue steps , one by one , this not needs designer or client desktop application, it's via browser Oct 4, 2016 at 14:06
-
I have updated my answer with more details , if you still need more clarification , please don't hesitate to tell me Oct 4, 2016 at 14:26
-
I understand now I had a brain fart, my bad! Thanks for all the Help! Oct 4, 2016 at 16:01
Doesn't work for me in O365 in 2019. This works:
// Hide New and Edit icons
function hideRibbonButtons() {
var edit = document.getElementById("Ribbon.ListItem.Manage.EditProperties-Large");
edit.style.display = "none";
var news = document.getElementById("Ribbon.ListItem.New");
news.style.display = "none";
}
// Fires "ribbontabselected" after the ribbon has been initialized after load
ExecuteOrDelayUntilScriptLoaded(function() {
var pm = SP.Ribbon.PageManager.get_instance();
pm.add_ribbonInited(function() {
SelectRibbonTab("Ribbon.ListItem", true); //set the Item tab as default
setTimeout(function() {
hideRibbonButtons();
}, 1000);
});
}, "sp.ribbon.js");