cancel
Showing results for 
Search instead for 
Did you mean: 

Setting iFrame size - different for various screen/monitor resolution

prabhu_s2
Active Contributor
0 Kudos

hi

I'm using iframe for one of the scenarios to display bsp page. Working on a different monitor resolution i found the size of the iframe is bit not consistent across. I reaslised that the iframe is using 'px - pixel' for defining the height and width. wondering if there is a way to make ti dynamic in a way to fit the various monitor resolutions?

ps: i tried '%' but little it helped.

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member184578
Active Contributor
0 Kudos

Hi,

% 's won't work for height property. You can create a Transparent container with Matrix Layout(and desired width in %) and place your iFrame in it and set the Stretch Horizontal and Vertical for Transparent Container which may help a bit.

Regards,

Kiran

ramakrishnappa
Active Contributor
0 Kudos

Hi Prabhu,

Create a transparent container and place the iframe element inside it and set the transparent container element's layout as matrix layout and set the layout width and height as stretched.

Otherwise, you need to get the resolution of screen and set the height and width of IFRAME ui element in WDDOMODIFYVIEW method as below


METHOD wddomodifyview .

   DATA lo_iframe TYPE REF TO cl_wd_iframe.

   DATA lv_width TYPE string.

   DATA lv_height TYPE string.

   " Process only for first time

   IF first_time = abap_true.

    lo_iframe ?= view->get_element('IFRAME').

    lv_width wdr_task=>client_window->if_wdr_client_info_object~client_width.

    lv_height wdr_task=>client_window->if_wdr_client_info_object~client_height.

   IF lo_iframe IS BOUND.

     lo_iframe->set_width( lv_width ).

     lo_iframe->set_height( lv_height ).

   ENDIF.

   ENDIF.

ENDMETHOD.

Note: if user changes the browser size at runtime, the iframe width / height may not change accordingly but upon any action you can again call this code to set based on modified window size.

Hope this helps you.

Regards,

Rama