I Want to set height of my Vf Page in inline vf as it is not taking content's full height. Just to came to know that the id of the iframe of inline vf is the id of apex page it is referring.

vfPageId = [SELECT Id, Name FROM ApexPage WHERE Name = 'YOUR_VF_PAGE_NAME'].Id;

Though I can get the Id of page in my controller, but don't want to take this approach as I have to create controller specially for this purpose. Is there is any other way around to get the Id of page


2 Answers 2


Use the $Component global variable to simplify referencing the DOM ID that is generated for a Visualforce component, and reduce some of the dependency on the overall page structure.

You can set the apex page id like below and can use $Component global variable to set the height of the same.

<apex:page id="thepage"></apex:page>

Or you can use the below approach,

<apex:page> <div id="my-timeline" style="**height:300px**; border: 1px solid #aaa"></div> </apex:page>

Or you can see, for example: Want to change the height of the home page component dynamically


If not writing the Apex Controller is a constraint, then you can work around this, by executing a Soql query using the REST API.

Execute following query by performing a GET call via the Salesforce REST API using AJAX methods such as jQuery.get() provided by Javascript libraries such as Jquery or equivalent, to retrieve the Id of the respective Visualforce Page.


You can test the above query using the REST Explorer tool within Workbench to view the query resultset returned as a JSON response.

Refer the following article to understand more about Executing a SOQL Query via the REST API

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .