Favoricône
Needs translation
Purpose
This plugin provides the ability to add and update a web page's favicon.
Use when
- Adding a mobile favicon to a web page.
- Dynamically updating the favicon of a web page.
Working example
How to implement
Add a mobile favicon:
- Add a favicon to the web page using a link element:
<link href="favion.ico" rel="icon" type="image/x-icon">
- Optionally specify the mobile favion's filename, path, rel attribute and sizes attribute:
<link href="favion.ico" rel="icon" type="image/x-icon" data-filename="my-mobile-favicon.ico" data-path="/path/to/favicon/" data-rel="apple-touch-icon-precomposed" data-sizes="57x57">
Update an existing favicon's href attribute:
- Using JavaScript, get a reference to the favicon's link element:
var $favicon = $( "link[rel='icon']" );
- Trigger the icon.wb-faviconevent on the favicon element:
 Note: the update of the favicon's href attribute will be based on its data-path and data-filename attributes.$favicon.trigger( "icon.wb-favicon" );
Configuration options
All configuration options of the plugin are controlled with data attributes:
| Option | Description | How to configure | Values | 
|---|---|---|---|
| data-filename | Filename of the mobile favicon. It is appended to the favicon's path (specified by data-path). | Set to the filename of the mobile favicon. | 
 | 
| data-path | Full path to the mobile favicon. | Set to the full path of the mobile favicon. | 
 | 
| data-rel | Favicon rel attribute. | Set to the desired rel attribute value of the favicon. | 
 | 
| data-sizes | Favicon sizes attribute. | Set to the desired sizes attribute value of the favicon. | 
 | 
Events
Document the public events that can be used by implementers or developers.
| Event | Trigger | What it does | 
|---|---|---|
| wb-init.wb-favicon | Triggered manually (e.g., $( "link[rel='icon']" ).trigger( "wb-init.wb-favicon" );). | Initializes the plugin and creates a mobile favicon if it doesn't already exist. Note: the favicon plugin will be initialized automatically unless the link element is added after the page has already loaded. | 
| wb-ready.wb-favicon(v4.0.5+) | Triggered automatically after the Favicon plugin initializes. | Used to identify when the Favicon plugin has initialized  | 
| wb-updated.wb-favicon(v4.0.5+) | Triggered automatically after the favicon update has completed. | Used to identify when the plugin has finished updating the favicon and to pass along what type of favicon was updated ( mobile,icon). | 
| mobile.wb-favicon | Triggered manually and during plugin initialization (e.g., $( "link[rel='icon']" ).trigger( "mobile.wb-favicon" );). | Adds or updates the mobile favicon on the web page. This will only update a mobile favicon that was added by the plugin. | 
| icon.wb-favicon | Triggered manually (e.g., $( "link[rel='icon']" ).trigger( "icon.wb-favicon" );). | Updates the favicon's hrefattribute based on itsdata-filenameanddata-pathattributes. | 
| wb-ready.wb(v4.0.5+) | Triggered automatically when WET has finished loading and executing. | Used to identify when all WET plugins and polyfills have finished loading and executing.  | 
Source code
Signaler un problème sur cette page
- Date de modification :