Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to redirect to the recommended browsers when the portal is accessed from a non-recommended browser

yin2
Giga Expert

Hello everyone,

We recognize that the recommended browsers for ServcieNow are as follows.
・ Google Chrome (from the latest version to the release version two years ago)
・ Microsoft Edge (from the latest version to the release version two years ago)
・ Firefox (from the latest version to the release version two years ago)
・ Safari (Safari 12.0 or later)

There is a concern that it will not work with non-recommended browsers such as input control processing, and unexpected values ​​may be input.

What we want to do is as follows,

If the portal screen is accessed from a browser which is not the recommended browser, the use of the website is blocked by redirecting to the recommended browsers. Of Course,There is no problem with Redirecting after logging in.

■ Question
1. If there is a client script to get the browser information (even if it is not a client script), Where is it getting the browser information?
2. When redirecting, I also want to send a message such as "Not available in your browser."

 

Thanks.

1 ACCEPTED SOLUTION

yin2
Giga Expert

Add the Script into the widget which is cloned from login widget .

Script is like the line from3 to 18.

find_real_file.png

//judge the browser
var agent = navigator.userAgent.toLowerCase();
 console.log("ABCD"+agent);
	
//write the redirect link
var redirectPass = 'https://www.microsoft.com/ja-jp/edge';

if (agent.indexOf("edg") != -1 || agent.indexOf("edge") != -1 || agent.indexOf("chrome") != -1 || agent.indexOf("safari") != -1 || agent.indexOf("firefox") != -1) {
 console.log("The browser is one of which Edge、chrome、safari、firefox");	
	
   } else {
  console.log("Browser is not anyone of which Edge、chrome、safari、firefox.");
//redirect
alert("The browser could not be using"); 
location.href = redirectPass;
   }

View solution in original post

2 REPLIES 2

yin2
Giga Expert

Add the Script into the widget which is cloned from login widget .

Script is like the line from3 to 18.

find_real_file.png

//judge the browser
var agent = navigator.userAgent.toLowerCase();
 console.log("ABCD"+agent);
	
//write the redirect link
var redirectPass = 'https://www.microsoft.com/ja-jp/edge';

if (agent.indexOf("edg") != -1 || agent.indexOf("edge") != -1 || agent.indexOf("chrome") != -1 || agent.indexOf("safari") != -1 || agent.indexOf("firefox") != -1) {
 console.log("The browser is one of which Edge、chrome、safari、firefox");	
	
   } else {
  console.log("Browser is not anyone of which Edge、chrome、safari、firefox.");
//redirect
alert("The browser could not be using"); 
location.href = redirectPass;
   }

Varshith Kuraga
Tera Guru

Today I was lucky to find this solution after searching many times. Thank you so much @yin2

 I have a question on SSO. Our employees use single sign-on and do not use how that will work.