cancel
Showing results for 
Search instead for 
Did you mean: 

Screen Personas 3.0 SP03 - detect user agent (WinGui / WebGui)

Former Member
0 Kudos

Hi experts,

is there a simple, working way to detect in scripting whether the current session is rendered by web browser or through Windows GUI?

We'd like to show e.g. a warning to users in case of using Windows GUI, that some of the features are not supported / working in our flavors.

Thanks for any advice!

Accepted Solutions (1)

Accepted Solutions (1)

Hi Merten,

You can use the following API to detect the GUI used:

session.info.guiType

guiTypeNumberrProvides the GUI runtime in which the current script is executed. Values are:
  • 0 (= SAP GUI for Windows)
  • 1 (= SAP GUI for Html)
  • 2 (= SAP GUI for Java)

The API documentation can be found on the server using the following URL:

http(s)://<host>:<port>/sap/bc/personas3/core/resources/doc/PersonasScriptingAPIDoc.html#GuiSessionInfo-prop-guiType

Best regards

Kranthi
SAP Screen Personas Team

former_member192584
Participant
0 Kudos

oops, missed to notice this API, Thank you Kranthi.

Regards,

Vigneshkkar.

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks, excellent tip!

former_member192584
Participant
0 Kudos

Hi Merten,

     The largest browsers working are chrome, Mozilla, Safari, Internet Explorer, Edge, Opera you can check for these browsers and display the message accordingly, try using the below code.


//Check for various browsers

var check_chrome = !!window.chrome && !!window.chrome.webstore;

var check_firefox = typeof InstallTrigger !== 'undefined';

var check_safari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;

var check_IE = !!document.documentMode;

var check_edge = !check_IE && !!window.StyleMedia;

var check_opera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;

//Display Alert

if (check_chrome || check_firefox || check_safari || check_IE || check_edge || check_opera)

    {

        alert("opened from browser!");

    }

else

{

     alert("opened from windows GUI");

}

Regards,

Vigneshkkar.