I am using this script to hide 'Edit' button from SharePoint ribbon on my custom webpart's ascx page and calling it in the page load:
function hideEdit() { var edit = document.getElementById("Ribbon.ListForm.Manage,EditItem-Large"); edit.style.display = "none"; alert ("I am an alert box!"); } _spBodyOnLoadFunctionNames.push("hideEdit"); and I am getting two annoying errors:
1)SCRIPT1004: Expected ';'
2)SCRIPT5007: Unable to get property 'style' of undefined or null reference
I have checked like 100 times, there is no semicolon missing. Any clue whats happening here?
editisundefined? maybe because"Ribbon.ListForm.Manage,EditItem-Large"does not look like a valid selector. Please try to learn some JS basics (like debugging). This would have made this mistake obvious.