function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

javascript to hide related list buttons on an object view page

hi i am trying to hide buttons on some related list areas on the contact view page but can't seem to get any success using javascript to scan for the buttons, any helpers?



Why not just remove the related list buttons from the page layout editor?




you can't for notes and attachments etc... i want to hide the new note button
You're not going to be able to hide that with Javascript.  JS on pages is served from a separate domain, so it can't touch the main page.
there must be a way
Can't i not get all the elements on the page i.e in this case the contact page and look for that element name i can see the name is newNote for that button :(

Not from a different domain you can't.  I guarantee you you will not be able to do this with Javascript.


You could replace the detail page with a Visualforce page that has an <apex:detail> and then put a custom Attachments related list at the bottom that has no Notes.