1

I am trying to remove the standard new button in recent list page of my custom object. But based on my research, Salesforce is not allowing javascript in its home page components anymore. Then there comes the recommendation of using Visualforce area home page component as an alternative, wherein one must create a vf page containing the javascript, then calling this page when creating a visualforce area home page component.

I've done this workaround, but still, it's not working.

Here's the vf page:

<apex:page >
    <html>
    <script type="text/javascript" src="https://c.ap2.visual.force.com/resource/1472886375000/jquery"></script> 

    <script type="text/javascript"> 

        $j = jQuery.noConflict(); 
        $j(document).ready(function hideButton(){ 
            var url = window.location.href; 
            var tabUrl = "https://ap2.salesforce.com/a03/o"; 
            if(url.indexOf(tabUrl) !== -1){
                var newBtn = $j('[name="new"]');
                newBtn.css({"visibility":"hidden"});
            }
        }); 
    </script> 
    </html>  
</apex:page>
2

A reason that Salesforce have stopped JavaScript in non-Visualforce home page components is that such JavaScript was able to make modifications to default layout pages because the home page components were being served from the same domain as the default layout pages. That ability to modify was seen by Salesforce to be a risk rather than a benefit.

By forcing the use of Visualforce to run JavaScript, that ability has been explicitly blocked. Visualforce is served from a different domain (e.g. https://na3.visual.force.com) than the default layout pages (e.g. https://na3.salesforce.com) and so the same-origin policy of browsers blocks the access.

You should be seeing the errors reported in your browser's JavaScript console. AFAIK there is now no JavaScript way to achieve what you are trying to do.

| improve this answer | |
  • sad to hear this, I hope they'll find a way to create solution for this someday. anyway, thanks for your response. – lol Sep 3 '16 at 10:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.