0

我正在建立一个网站,它在标准浏览器上完美显示,即 Chrome、Firefox、Opera 和 IE8..

如果使用这些浏览器以外的其他浏览器,有没有办法显示消息?

而且,如果可能的话,如果在手机上使用非标准浏览器,则显示一条消息,因为大多数标准浏览器都是混合的..(Android)

如果版本低于 7,我发现很多教程可以做到这一点,但对于非标准浏览器则没有,如果有人可以向我指出一个非标准浏览器的教程,它会做......

4

3 回答 3

1

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.

于 2013-06-10T18:05:04.487 回答
0

如果绝对无法将警告显示为弹出窗口,您始终可以通过将用户转发到显示警告消息的网页来做到这一点。

它看起来有点尴尬,但如果没有其他选择,它应该可以工作。

所有浏览器都应该至少支持基本的 HTML 标签。

于 2013-06-10T17:45:08.550 回答
0

您可以通过名为User-Agent. 使用 servlet 或 HTTP 过滤器来验证此标头并在需要时将响应重定向到错误页面。

于 2013-06-10T17:26:14.297 回答