cancel
Showing results for 
Search instead for 
Did you mean: 

Closing external window with BSP / Javascript

Former Member
0 Kudos

I refer to the following thread:

I need to find a solution to close an external explorer / or Netweaver Business Client window.

Thank you for you help.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello,

first of all you nead two BSP pages: open.htm and close.htm which open and close your external browser windows:

<b>open.htm</b>

<htmlb:content design="design2003" >
  <htmlb:document>
    <htmlb:documentHead>
      <script language="JavaScript">
      <!--
        var nw;
        nw = window.open('','HelpWindow','toolbar=no');
        nw.location.href = '<%= l_url %>';
        nw.name = 'HelpWindow';
        nw.focus();
        top.close();
      -->
      </script>
    </htmlb:documentHead>
  </htmlb:document>
</htmlb:content>

don't forget to add a parameter (i.e. l_url type string) in the bsp configuration and set it to auto !

<b>close.htm</b>

<htmlb:content design="design2003" >
  <htmlb:document>
    <htmlb:documentHead>
      <script language="JavaScript">
      <!--
        var nw;
        nw = window.open('','HelpWindow','');
        nw.close();
        top.close();
      -->
      </script>
    </htmlb:documentHead>
  </htmlb:document>
</htmlb:content>

Next step is to create a method in your Component Controller to open a window.

Here you are free, which technique to use.

METHOD show_popup .

  DATA:
    l_cmp_api TYPE REF TO if_wd_component,
    l_window_manager TYPE REF TO if_wd_window_manager,
    l_comp_info TYPE REF TO if_wd_rr_component,
    l_final_window TYPE REF TO if_wd_window.

  l_cmp_api = wd_this->wd_get_api( ).
  l_window_manager = l_cmp_api->get_window_manager( ).

  CALL METHOD l_cmp_api->get_component_info
    RECEIVING
      component_info = l_comp_info.

  DATA: l_app_name TYPE string.
  DATA: l_url TYPE string.

  l_app_name = l_comp_info->get_name( ).
  
* add your path to your open.htm and your specific url
  l_url = "./open.htm?url=http://www.google.com"

  CALL METHOD l_window_manager->create_external_window
    EXPORTING
      url            = l_url
      title          = 'HelpOpener'
      modal          = abap_false
      has_menubar    = abap_false
      is_resizable   = abap_false
      has_scrollbars = abap_false
      has_statusbar  = abap_false
      has_toolbar    = abap_false
      has_location   = abap_false
    RECEIVING
      window         = l_final_window.


  CALL METHOD l_final_window->set_window_position
    EXPORTING
      left = 0
      top  = 0.

  CALL METHOD l_final_window->set_window_size
    EXPORTING
      width  = '1px'
      height = '1px'.

  CALL METHOD l_final_window->open
    .

ENDMETHOD.

<b>How does it work ?</b>

The method opens the window help.htm (30x30px) which opens your file you wanna show. Then the opener window closes again. Important is, that this window now has a name "HelpWindow". With this name you are free to get a window reference in JavaScript whereever you want.

To close the window again, just open the close.htm bsp. It works similar to the open.htm page.

I hope I could help you

Best Regards

Former Member
0 Kudos

Thanks a lot!

Answers (0)