jReject: jQuery Browser Rejection

Current Version: v0.7-Beta
Last Updated: 05/26/2010 18:10:35

Description: jReject provides a simple, robjust, light-weight way to display rejections based on a the browser, specific browser version, specific platforms, or rendering engine. Provides full customization of the popup. Uses no CSS file (by default), and can easily be used on page load or during a specific page event. Also provides a flexible way to beautifully and cleanly display custom browser alternatives in the popup.

Depends On:
jQuery 1.3+
jQuery Browser Plugin (Included By Default)

Download

If you are a developer familiar with using jQuery, continue with the documentation below...

Documentation

The object is called "reject", and can be invoked once the document is ready ($.reject() or jQuery.reject()). The first parameter contains all the options and configurations for the plugin.

Default Options

Here are the default options for the first parameter of the reject object. You only need to specify those which you wish to override.

        options = {
                reject : { // Rejection flags for specific browsers
                        all: false, // Covers Everything (Nothing blocked)
                        msie5: true,msie6: true // Covers MSIE 5-6 (Blocked by default)
                        /*
                                Possibilities are endless...

                                msie: false,msie5: true,msie6: true,msie7: false,msie8: false, // MSIE Flags (Global, 5-8)
                                firefox: false,firefox1: false,firefox2: false,firefox3: false, // Firefox Flags (Global, 1-3)
                                konqueror: false,konqueror1: false,konqueror2: false,konqueror3: false, // Konqueror Flags (Global, 1-3)
                                chrome: false,chrome1: false,chrome2: false,chrome3: false,chrome4: false, // Chrome Flags (Global, 1-4)
                                safari: false,safari2: false,safari3: false,safari4: false, // Safari Flags (Global, 1-4)
                                opera: false,opera7: false,opera8: false,opera9: false,opera10: false, // Opera Flags (Global, 7-10)
                                gecko: false,webkit: false,trident: false,khtml: false,presto: false, // Rendering Engines (Gecko, Webkit, Trident, KHTML, Presto)
                                win: false,mac: false,linux : false,solaris : false,iphone: false, // Operating Systems (Win, Mac, Linux, Solaris, iPhone)
                                unknown: false // Unknown covers everything else
                        */
                },
                display: ['firefox','chrome','msie','safari','opera','gcf'], // What browsers to display and their order
                browserInfo: { // Settings for which browsers to display
                        firefox: {
                                text: 'Firefox 3.5+', // Text below the icon
                                url: 'http://www.mozilla.com/firefox/' // URL For icon/text link
                        },
                        safari: {
                                text: 'Safari 4',
                                url: 'http://www.apple.com/safari/download/'
                        },
                        opera: {
                                text: 'Opera 10.5',
                                url: 'http://www.opera.com/download/'
                        },
                        chrome: {
                                text: 'Chrome 5',
                                url: 'http://www.google.com/chrome/'
                        },
                        msie: {
                                text: 'Internet Explorer 8',
                                url: 'http://www.microsoft.com/windows/Internet-explorer/'
                        },
                        gcf: {
                                text: 'Google Chrome Frame',
                                url: 'http://code.google.com/chrome/chromeframe/',
                                allow: { all: false, msie: true } // This browser option will only be displayed for MSIE
                        }
                },
                header: 'Did you know that your Internet Browser is out of date?', // Header of pop-up window
                paragraph1: 'Your browser is out of date, and may not be compatible with our website. A list of the most popular web browsers can be found below.', // Paragraph 1
                paragraph2: 'Just click on the icons to get to the download page', // Paragraph 2
                close: true, // Allow closing of window
                closeMessage: 'By closing this window you acknowledge that your experience on this website may be degraded', // Message displayed below closing link
                closeLink: 'Close This Window', // Text for closing link
                closeURL: '#', // Close URL
                closeESC: true, // Allow closing of window with esc key
                closeCookie: false, // If cookies should be used to remmember if the window was closed (see cookieSettings for more options)
                // Cookie settings are only used if closeCookie is true
                cookieSettings: {
                        path: '/', // Path for the cookie to be saved on (should be root domain in most cases)
                        expires: 0 // Expiration Date (in seconds), 0 (default) means it ends with the current session
                },
                imagePath: '', // Path where images are located
                overlayBgColor: '#000', // Background color for overlay
                overlayOpacity: 0.8, // Background transparency (0-1)
                fadeInTime: 'fast', // Fade in time on open ('slow','medium','fast' or integer in ms)
                fadeOutTime: 'fast' // Fade out time on close ('slow','medium','fast' or integer in ms)
        }
            

Optional Event Methods

options.beforeReject(opts)

Called before rejection is determined.


options.afterReject(opts)

Called after rejection window has been created, for browsers that matched the rejection settings.


options.onFail(opts)

Called if the browser does NOT meet the rejection requirements


options.beforeClose(opts)

Called after close button is clicked, but before popup is actually closed.


options.afterClose(opts)

Called after rejection popup is closed


Example Usage

Default Settings

Run Demo

If nothing happened when you ran this demo, that is because you are not using IE6!. By default (no settings specified) the reject function only rejects IE5 and IE6.

Example Code

        $('#demo1').click(function() {
            $.reject(); // Default Settings
            return false;
        });
            

Customize Browsers To Reject

Run Demo

In this example pretty much every browser should be rejected.

Example Code

        $('#demo2').click(function() {
            $.reject({
                reject: {
                    safari: true, // Apple Safari
                    chrome: true, // Google Chrome
                    firefox: true, // Mozilla Firefox
                    msie: true, // Microsoft Internet Explorer
                    opera: true, // Opera
                    konqueror: true, // Konqueror (Linux)
                    unknown: true // Everything else
                }
            }); // Customized Browsers

            return false;
        });
            

Customize Popup Text

Run Demo

In this demo we use customized text in the popup window. This demo uses the following properties:
header, paragraph1, paragraph2, closeMessage
See Also closeLink

Example Code

        $('#demo3').click(function() {
            $.reject({
                reject: { all: true }, // Reject all renderers for demo
                header: 'Your browser is not supported here', // Header Text
                paragraph1: 'You are currently using an unsupported browser', // Paragraph 1
                paragraph2: 'Please install one of the many optional browsers below to proceed', // Paragraph 2
                closeMessage: 'Close this window at your own demise!' // Message below close window link
            }); // Customized Text

            return false;
        });
            

Customize Browsers To Suggest

Run Demo

Using the display option, you can define which browsers to suggest, and the order in which to suggest them.
GCF is supported, but only displayed for IE users by default.

Default: ['firefox','chrome','msie','safari','opera','gcf']

Example Code

        $('#demo4').click(function() {
            $.reject({
                reject: { all: true }, // Reject all renderers for demo
                display: ['firefox','chrome','opera'] // Displays only firefox, chrome, and opera
            });

            return false;
        });
            

Customize Your Own Browser Suggestion

Run Demo

You can even add a customized browser to the list, and display it in any order you want.

Note: To add your own icon, you need to create a 'browser_{browserName}.gif' file and place it in your imagePath directory with the other images.
Image Dimensions: 100x100
Download browser_flock.gif (3.82 KB)

Example Code

        $('#demo5').click(function() {
            $.reject({
                reject: { all: true }, // Reject all renderers for demo
                display: ['flock','safari','opera'], // Displays only custom "Flock" browser, safari and opera.
                browserInfo: {
                    flock: { // Specifies browser name and image name (browser_flock.gif)
                        text: 'Flock 2+', // Text Link
                        url: 'http://flock.com/' // URL To link to
                    }
                }
            });

            return false;
        });
            

Display Once Per Session

Run Demo

By using the closeCookie option, you can make the window only appear once per session.
After it pops up the first time, this demo will not popup again until next browser session.

Note: This requires the ability to close the window. If close is false the cookie will never be set.

Example Code

        $('#demo6').click(function() {
            $.reject({
                reject: { all: true }, // Reject all renderers for demo
                closeCookie: true // Set cookie to remmember close for this session
            });

            return false;
        });
            

Disable ability to close window

Run Demo

The close option allows you to hide the closeLink or closeMessage elements from displaying.
This prevents the user from closing the window. If you use this on a onLoad event, the user will never be able to use your site.

Note: Testing this demo will require you to refresh the page to close out the popup window.

Example Code

        $('#demo7').click(function() {
            $.reject({
                reject: { all: true }, // Reject all renderers for demo
                close: false, // Prevent closing of window
                paragraph1: 'You will not be able to close this window', // Warning about closing
                paragraph2: 'To exit, you must refresh the page' // Display refresh link
            });

            return false;
        });