1

I have a VisualForce page with an <apex:iframe> component embedded into it, however when I change it to a regular HTML iFrame, it still seems able to display the page fine with no problems.

What're the differences between the Apex component and regular iframe? I had a feeling a regular iframe wouldn't be able to access the visualforce page I needed, but if it can, why should I use the provided apex component instead?

Cheers,

Sam

1

You should check the Documentation

<apex:iframe src="http://www.salesforce.com" scrolling="true" id="theIframe"/>

It renders into this:

<iframe height="600px" id="theIframe" name="theIframe" src="http://www.salesforce.com" width="100%"></iframe>

As Mukesh Verma has already commented that Visualforce tags provide certain attributes which are easy to use and make life of Developer very easy as you don't need to write extra code for them.

I haven't found any DOC which specifically compares the apex:iframe with iframe although here are several benefits of using Visualforce

As far as i understand visualforce tags are higher level layer on the basic tags so if something get change in the basic component you don't need to worry about that.

| improve this answer | |
  • But I've checked that documentation, and it provides no reason as to why I'd use it in place of a regular iFrame. Is it more secure? Is there an advantage to page speed? Or is it literally a little bit quicker to type because I don't have to add all the attributes? – user24634 May 25 '16 at 10:48
  • To clarify, I understand that most of the apex components have a valid use, such as a pageBlockTable to avoid having to create and style our own tables, but why did Salesforce add a component that doesn't seem to add any noticeable benefit? – user24634 May 25 '16 at 10:50
  • 3
    There are advantages that comes with apex components. For example you are control rendering of <apex:iframe > by using rendered property. Consider business use cases like show iframe only if some conditions are met. Similarly src can be binded to controller to dynamically control URL in apex logic. – Mukesh Verma May 25 '16 at 11:02
  • @Frodo I'm pretty sure the id attribute will render differently than what you have there. – Adrian Larson May 25 '16 at 14:49
  • @AdrianLarson Yeah Probably this will be a composite ID.But i took this directly from documentation only for representational purpose. – Mr.Frodo May 25 '16 at 17:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy