📜 ⬆️ ⬇️

Display an outdated browser notification using jReject

Many websites display warnings about outdated browsers or even send the user to install a new browser or Google Chrome Frame.
jReject is a special jQuery plugin that allows you to display such notifications with a few lines of code.

jQuery jReject


Configuring blocked browsers


The plugin allows you to flexibly customize the list of browsers whose users will see the notification.
For example, to give a message to users of unknown browsers, as well as Firefox 2 and Internet Explorer 5, it is enough to configure the plugin as follows:
')
$ .reject ({
reject: {
msie5: true
msie6: false ,
firefox2: true
unknown: true
}
});


The fifth and sixth versions of Internet Explorer are automatically blocked by the plugin, so if you want to let IE6 users to the site without any obstacles, you must specify this separately (msie6: false ).

The plugin allows you to specify not only certain versions of browsers, but also their entire families, engines, and operating systems. Full list of used symbols:

GroupKeywords
Operaopera, opera7, opera8, opera9, opera10
Google chromechrome, chrome1, chrome2, chrome3, chrome4
Firefoxfirefox, firefox1, firefox2, firefox3
Internet Explorermsie, msie5, msie6, msie7, msie8
Safarisafari, safari2, safari3, safari4
Konquerorkonqueror, konqueror1, konqueror2, konqueror3
Enginesgecko, webkit, trident, khtml, presto
OSwin, mac, linux, solaris, iphone
All the restunknown


Browsers Offered


A list of modern browsers that are offered for installation can be easily configured manually. For example, the following code can be used to display an offer for IE users to install Google Chrome Frame:
$ .reject ({
reject: {msie: true , firefox1: true },
browserInfo: {
gcf: {
text: 'Google Chrome Frame' ,
url: 'http://google.com/chromeframe' ,
allow: {all: false , msie: true }
// Forbid to show Google Chrome Frame button for all browsers except IE
}
}
});


Useful options


The plugin supports a number of options, the meaning of which is quite clear from their names.



Features


Right in the plugin itself, the standard set of browsers offered is included, along with their versions that have long been outdated. Despite the fact that the plugin was updated less than a month ago, it still offers to install Chrome 18 or Opera 11 by default. In order to correct this misunderstanding, you just need to specify the current versions in the plugin code itself, or remove the version altogether, leaving only browser names. The second option, of course, will be much more correct - hardly anyone will constantly update the data with the release of new versions of browsers. You can also manually specify a list of browsers with their current versions when calling the plugin.

Another important point: in order to correctly display the logos of browsers, you must specify the address of the directory where they are located in the imagePath parameter. The default path is ./images/ .

Links


Download jReject and get acquainted with more detailed examples of its use on the site of the plugin.

Source: https://habr.com/ru/post/150690/


All Articles