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

How to Hide embedded VF page on detail page using Javascript in the VF page

Hi I have a VF page included on Account page layout.


(I dont want to create seperate Pagelayouts because the render citeria may change )


I want to hide or show this VFpage based on Running users profile. I tried using "Rendered" BUT when i hide the page using "Rendered= false".

A BIG whitespage is shown in place of the VF page.


I tried using Javascript. window.resizeTo(800,200). But this is only working for IE6.

Please help 



This is a common problem and one to which there is no solution I'm afraid.  The visualforce page that is embedded into the record view comes from a different server to the standard view page, so most browsers will block attempts by either page to access each others properties using javascript, as this is considered a Cross Site Scripting attack.




Get the Iframe id of the VFp. Iframe Id is nothing but VFP Id. You can query it by Select Id from ApexPage where Name="your VFP Name" and then this iframe Id you can resize your page by setting the height and width properties of Iframe like:

parent.document.getElementById("the Iframe Id").setAttribute("height","200");

parent.document.getElementById("the Iframe Id").setAttribute("width","800");


I think this should work for pageLayout.