Where can I get the URL for adding a VF page through iframe to a custom lightning component?
Clash Royale CLAN TAG#URR8PPP
Where can I get the URL for adding a VF page through iframe to a custom lightning component?
Where can I get the URL for adding a VF page through iframe
to a custom lightning component?
iframe
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"/>
<iframe src="!'myURL'" width="100%" height="300px;" frameBorder="0"/>
Where can I get myURL
?
myURL
1 Answer
1
You will need to provide the src
here. It actually is the absolute url to your VF page along with your instance url.
src
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:
myVFPage
https://your-subdomain.my.salesforce.com
<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:
init
<iframe src="{!v.baseURL + '/apex/myVFPage'" width="100%" height="300px;" frameBorder="0"/>
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
I have answered a previous question about this you could refer that. salesforce.stackexchange.com/questions/222179/…
– codeyinthecloud
3 hours ago