Search Here

apex: iframe Component in Visualforce Page

 The <apex: iframe> is another important component in the Visualforce page that creates an inline frame within the Visualforce page. It allows users to keep information visible when other information is scrolled or replaced.


The HTML pass-through attributes are supported by this component by using the "html-" prefix.


The <apex: iframe> component has the following attributes:


1. frameborder

The frameborder is a Boolean type attribute used to specify whether a border should surround the inline frame or not. The boolean value true is set as the default value for this attribute.


Syntax


<apex:iframe frameborder="true"></apex:iframe>  

2. height

The height is a string-type attribute used to specify the height of the inline frame. The value can be defined in percentage or pixels. By default, its value is set to 600px.


Syntax


<apex:iframe height="500px"></apex:iframe>  

3. id

The id is a string-type attribute, i.e., a unique identifier that allows this component to be referenced by other components on the page.


Syntax


<apex:iframe id="frameId"></apex:iframe>  

4. rendered

The rendered is a Boolean type attribute that specifies whether this component needs to be rendered on the page or not. The boolean value true is set as the default value for this attribute.


Syntax


<apex:iframe rendered="false"></apex:iframe>  

5. scrolling

The scrolling is a Boolean type attribute used to specify whether this component needs to be scrolled on the page or not. The boolean value true is set as the default value for this attribute.


Syntax


<apex:iframe scrolling="false"></apex:iframe>  

6. src

The src is a string type attribute, i.e., a URL that specifies the initial contents of the inline frame. We can define a URL either of the external website or another page in the application.


Syntax


<apex:iframe src="{$IFrameResource.MyAsset}" scrolling="true" id="theIframe"></apex:iframe>  

7. title

The title is a string-type attribute that defines the text that needs to display as a tooltip when the user's mouse pointer hovers over this component.


Syntax

AD


<apex:iframe title="iframe title"></apex:iframe>  

8. width

The width is a string-type attribute used to specify the width of the inline frame. The value can be defined in percentage or pixels. By default, its value is set to 600px.


Syntax


<apex:iframe width="400px"></apex:iframe>  

Let's take an example to understand how we can use the <apex: iframe> component on the Visualforce page.


<apex:page showHeader="false">  

    <apex:pageBlock >  

        <apex:iframe height="400px" src="https://www.javatpoint.com/" scrolling="true" id="theIframe"/>  

    </apex:pageBlock>  

</apex:page>  

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.