Legacy platform

IFrame widget

The IFrame widget is a special widget that can be used to embed a different application. This widget creates an HTML iframe.

IFrame widget supports the following attributes:
  • frameId - String. The identifier of the iframe.
  • frameSrc - String. The src attribute for iframe that corresponds to the URL of the page to load.
    Note: Some web sites, for example, google or yahoo prevent themselves from being embedded in an iFrame contained in a different application. Therefore, ensure that the necessary web sites do not impose such restrictions.
  • applyCSRF - Boolean. Indicates whether the CSRF token must be part of the URL for iframe. The default value is true.
  • qryParamsList - Array. Contains an array of query parameters that must be part of URL for iframe. Each query parameter is a JSON object and contains the following attributes:
    • name - String. The parameter name.
    • value - String. The parameter value.
  • frameClass - String. Use the CSS class for styling iframe. Defaults to scIFrame.
  • frameScrolling - String. Sets the scrolling attribute for iframe. To enable scrolling within iframe, set the value of this attribute to yes. By default, the value is set to no. The value, auto is also available.
  • frameborder - Number. Specifies whether to display a border for iframe. Valid values are 0 and 1. The default value is 0.

You can add an IFrame widget in your application in any of the following methods:

  • Declarative - Create an HTML element in the <Screen>.html file as provided in the following sample code.
    <div data-dojo-type="sc/plat/dojo/widgets/IFrame" data-dojo-props=" uId: 'customiframe', frameId: 'sampleId', frameSrc: '<provide your application URL here>',
     applyCSRF:true,frameScrolling: 'yes' ">
    </div> 	 
  • Programmatically - Use the sc.plat.dojo.utils.WidgetUtils.createIframeWidget JavaScript utility. For more information about the createIframeWidget widget method, see the JavaScript documentation.
    • Arguments
      • Screen - The screen instance in which the widget is to be created.
      • uId - The uId of the new widget to create. If you pass as null, auto generated uId is returned.
      • configObj - The JSON object that contains all the attributes such as frameId, frameSrc, applyCSRF, and others required to create an IFrame. The following code explains the structure of the JSON object:
        var iframeUId = _scWidgetUtils.createIframeWidget(this, null, {"IFrame": {frameId: 'pqr',frameSrc: 
        '<provide your application URL here>', applyCSRF: true, frameScrolling: 'yes' }	});
      • Return value - The uId of the newly created widget is returned, which is same as widgetUId.

    To place the created widget on the screen, use the placeAt widget method provided by Dojo.

Update the application loaded in IFrame widget

Use the IFrame widget that you created to either load a separate application or reload an existing application with different parameters by using the sc.plat.dojo.utils.WidgetUtils.setIFrameSrc JavaScript utility.

Arguments:
  • screenInstance - The screen instance in which the IFrame widget is present.
  • iframeUId - The uId of the IFrame widget.
  • src - The URL of the application to be loaded.
  • qryParamsList - Optional. Contains an array of query parameters that must be part of the URL for iframe. Each query parameter is a JSON object and contains the following attributes:
    • name - String. The parameter name.
    • value - String. The parameter value.