2

Where can I get the URL for adding a VF page through iframe to a custom lightning component?

1 I create a VF page.

2 I know that I can display it in lightning using the following approach

<iframe src="{!'myURL'}" width="100%" height="300px;" frameBorder="0"/>

Where can I get myURL?

4

You will need to provide the src here. It actually is the absolute url to your VF page along with your instance url.

So let's say you have a VF page named myVFPage, and that your instance URL is say https://your-subdomain.my.salesforce.com, then your code should look like as below:

<iframe src="https://your-subdomain.my.salesforce.com/apex/myVFPage" width="100%" height="300px;" frameBorder="0"/>

And to add more details to this, you may like to actually maintain a variable on your component which gets populated during the init of your component which gets populated with your instance URL. You will need to make a server trip here though. But with this approach, you don't have to hard-code the URL whenever you deploy the code to other sandboxes. And that you use that variable to construct the URL. Something as below:

<iframe src="{!v.baseURL + '/apex/myVFPage'" width="100%" height="300px;" frameBorder="0"/>

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.