Niket Malik
Niket Malik

Reputation: 1105

Display a warning for non standard browsers

I'm building a website, it displays perfect on standard browsers i.e Chrome, Firefox, Opera and IE8..

Is there a way to display a message if other than these browsers are used?

And also, if possible, display a message if non standard browser is used on a mobile phone as most of the standard browsers are hybrid..(Android)

I found lots of tutorial to do so if ie version less than 7, but none for non standard browsers, if someone could point me to a tutorial for non standard browser that would do to..

Upvotes: 0

Views: 250

Answers (3)

grepit
grepit

Reputation: 22382

As Alex Kreutznaer above explained you can use the user agent information. Just to provide a base code for you. Here is how you can do it.

Note, this information is not reliable. Browser can and do lie about who they are and what OS they run on because user agent information can be changed but for most of your users, it does the job. In term of displaying a warning you can send the value from your servlet once you detected it and show a message on the page.

String userAgent = request.getHeader("User-Agent");

you would need then group of if statement to identify the browsers you want or don't want in order to display or hide your warning.

here is a link with code you could use to identify the browser.

Upvotes: 1

Alex Kreutznaer
Alex Kreutznaer

Reputation: 1170

If there is absolutely no way to show a warning as a pop up, you can always do it by forwarding users to a web page, that shows the warning message.

It looks sort of awkward, but if there is no other choice, it should work.

All browsers are supposed to support at least basic HTML tags.

Upvotes: 0

AlexR
AlexR

Reputation: 115338

You can identify HTTP client via header named User-Agent. Use servlet or HTTP filter that verifies this header and redirects response to error page if needed.

Upvotes: 0

Related Questions