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
DJ Rock your own styleDJ Rock your own style 

Access elements of parent record from inline visualforce page

Hi All,

 

I have an inline vf in a record detail page. I would like to hide some attributes of the record detail (say notes and attachments) by calling a javascript from the inline. Below is the snippet:

 

<script>
    
    var previousOnload = window.onload;        
    window.parent.onload = function() {
        if (previousOnload) {
            previousOnload();
        }
document.getElementsByClassName('listRelatedObject Custom78Block')[0].style.display = 'none'
    }

</script>

 

Here i ve got the class name by inspecting the element in browser. But when i try to run this, i get an error in the error console as: Permission denied to access property onload......

 

Is there any workaround for this?

 

Thanks in advance,

 

Dave.

Best Answer chosen by Admin (Salesforce Developers) 
DJ Rock your own styleDJ Rock your own style

Hi Bob,

 

Thanks for the quick reply. Is there any other way to do this?

 

My requirement is to remove the notes and attachment related list from record detail page but the hover link for the same should be visible on the top.

I am displaying all the notes and attachments of this object and the related child objects in the inline vf, so need to remove the standard N & A related list but still make it available on hover on top of page.

 

Thanks and regards,

Dave.

All Answers

bob_buzzardbob_buzzard

You can't do that I'm afraid - as the inline VF page is served from a separate server, the browser blocks any attempt to access the standard page dom as a cross site scripting attack.

DJ Rock your own styleDJ Rock your own style

Hi Bob,

 

Thanks for the quick reply. Is there any other way to do this?

 

My requirement is to remove the notes and attachment related list from record detail page but the hover link for the same should be visible on the top.

I am displaying all the notes and attachments of this object and the related child objects in the inline vf, so need to remove the standard N & A related list but still make it available on hover on top of page.

 

Thanks and regards,

Dave.

This was selected as the best answer
bob_buzzardbob_buzzard

The only way I know of to influence the standard page is to embed an html area in the sidebar.  This can then change the page based on the contents.  However, I'm not sure that will be able to know about th embedded VF, so it may not be entirely suitable for your purposes.