https://github.com/phpdude/browser.js
browser.js - Lightweight Browser & OS detection library like Modernizr.
https://github.com/phpdude/browser.js
Last synced: 5 months ago
JSON representation
browser.js - Lightweight Browser & OS detection library like Modernizr.
- Host: GitHub
- URL: https://github.com/phpdude/browser.js
- Owner: phpdude
- License: mit
- Created: 2014-05-30T17:54:09.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2014-05-30T21:38:56.000Z (about 12 years ago)
- Last Synced: 2025-01-24T11:25:51.609Z (over 1 year ago)
- Homepage: http://phpdude.github.io/browser.js/
- Size: 406 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
- License: LICENSE.md
Awesome Lists containing this project
README
# [browser.js](https://github.com/phpdude/browser.js/) v0.1.1
browser.js makes it easy to write conditional CSS based on device operating system and web browser.
### Online demo
You can go to online [demo](http://phpdude.github.io/browser.js/demo/).
### Examples
browser.js inserts css classes into `` element.
### Mac OS & Firefox

### iPad Emulator & Safari

### Mac OS & Google Chrome

## Usage
Just include the script. The script then updates the `` section with the appropriate classes based on os & browser names detected by [platform.js](https://github.com/bestiejs/platform.js).
``` html
```
### Embeded class names
browser.js add classes to `` element by masks
```
ua-#{ua}
os-#{os}
#{os}-#{ua}
ua-#{ua}#{version} (Major version number)
```
Example for Mac OS & firefox
```
ua-firefox
os-mac
mac-firefox
ua-firefox29
```
### Support no-js/nojs `` classes.
browser.js will remove no-js or nojs classes from `` element.
### Utilities
#### browser.noConflict()
Run browser.js in noConflict mode, returning the browser variable to its previous owner.
Returns a reference to the browser object.
#### browser.js JavaScript methods
You can get browser detected classes by javascript api.
``` html
console.log(browser.classes());
```
browser.js doesn't remove any extra classes added in `` section.
### Usage
In your CSS you can use added browser.js classes for making elegant hacks for selected browsers. For example you can make hacks for all IE and IE6.
``` css
.ua-ie .adv {
margin-top: 15px;
}
.ua-ie6 .adv {
margin-top: 17px;
}
```
### Contributor
Alexandr Shurigin (aka [phpdude](https://github.com/phpdude/))
### Thanks to
##### [platform.js](https://github.com/bestiejs/platform.js)
platform.js used for browsers & OS detection capabilities.