Favicon: Make a use of your favicon with badges, images or videos

Favicon.js jQuery plugin allows you tu to use your favicon with badges, images or videos

Animate your favicon with animated badges (slide, fade, pop, etc…).

You can customize type of animation, position, background color and text color.

Download: https://github.com/ejci/favico.js

Demonstration: http://lab.ejci.net/favico.js/

Plugin homepage: http://lab.ejci.net/favico.js/

Implementation:

  1. First, include the jQuery files
<!-- jQuery files -->
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="favicon-0.3.4.min.js"></script>

2. Now, call Favicon plugin

<script type="text/javascript">
  $(document).ready(function(){
    // Simple call
    var badge = 5; // Set badge value
    var favicon = new Favico(); // Create favicon
    
 
    // Call Favicon plugin with options
    var badge = 5; // Set badge value
    var favicon = new Favico({
        animation : 'popFade', // set animation type
        bgColor : '#000', // set the badge bgcolor
        textColor: '#fff', // set the badge text color
        fontFamily : 'Arial' // set the badge font-family property
    });
  });
</script>

3. Play with badge values

<script type="text/javascript">
  $(document).ready(function(){
 
    // Add +1 to bagde value when clicking on a button with id="plusOne"
    // exemple <button id="plusOne">+1</button>
    $('#plusOne').click(function() {
        badge = badge + 1;
        favicon.badge(badge);
    });
 
    // Add -1 to bagde value when clicking on a button with id="minusOne"
    // exemple <button id="minusOne">-1</button>
    $('#minusOne').click(function() {
        badge = (badge-1 < 0) ? 0 : (badge - 1);
        favicon.badge(badge);
    });
 
    // Reset badge value = hide badge
    // exemple <button id="reset">Reset badge</button>
    $('#reset').click(function() {
        favicon.reset();
    });
  });
</script>

4. Show image, video or webcam instead of your favicon

<script type="text/javascript">
  $(document).ready(function(){
 
    // Show an existing image on your webpage
    var favicon=new Favico();
    var image=document.getElementById('imageId');
    favicon.image(image);
 
    // Show a video instead of your classical favicon
    var favicon=new Favico();
    var video=document.getElementById('videoId');
    favicon.video(video);
    //stop the video
    favicon.video('stop');
 
    // Show your webcam instead of your classical favicon
    var favicon=new Favico();
    favicon.webcam();
    //stop
    favicon.webcam('stop');
  });
</script>

Options:

bgColorStringDefault : #d00 – Badge background color
textColorStringDefault : #fff – Badge text color
fontFamilyStringDefault : sans-serif – Text font family (Arial, Verdana, Times New Roman, serif, sans-serif,…)
fontStyleStringDefault : bold – Font style (normal, italic, oblique, bold, bolder, lighter, 100, 200, 300, 400, 500, 600, 700, 800, 900)
typeStringDefault : circle – Badge shape (circle, rectangle)
positionStringDefault : down – Badge position (up, down, left, upleft)
animationStringDefault : slide – Badge animation type (slide, fade, pop, popFade, none )
elementIdBooleanDefault : false – Image element ID if there is need to attach badge to regular image

Screenshots

How to Create Custom CSS, jQuery Autocomplete Plugin

Web developers often use autocomplete features in websites as a part of their work. Yet lot of good …

How to Make Sticky Sidebar Using jQuery and CSS

Sticky sidebar is an essential part of web development. Not in all cases but for some cases where ou…

Selectors, Animation, and AJAX – jQuery Tutorial And Examples

By now I’m sure you have grasped at least the basics and simplicity of the jQuery library. Now it’s …

s3Slider jQuery Plugin & Tutorial

The s3Slider jQuery plugin is made by example of jd`s smooth slide show script. Usage: HTML: Sample …

jQuery Optimization: Avoid Unnecessary Selector

Common subexpression elimination is a common way to optimize any programming code. Doing unnecessary…

Fading Links Using jQuery: dwFadingLinks

Earlier this month, we posted a MooTools script that faded links to and from a color during the mous…