Online computer courses, code, programming tutorial and sidebar information for monitoring Canadian S&P/TSX index. Build friendship and networking. Welcome to visit my blogs often!!! I also have two other sites: YouTube Channel and Google site.
Adsense
Popular Posts
- Formatting my post
- How to blend adsense inside your post?
- PHPWind-- A PHP forum script applcaition in China
- Notepad++ - Add C++ compiler
- PHP: add a download as pdf file button in report page
- ActionScript 3.0 demo: create a falling snow in flash CS6
- phpexcel toggle expand and hide column in EXCEL and summary
- Datatable export excel wraptext and newline
- PHP connect IBM db2 database in XAMPP
- PHP - Export Content to MS Word document
Thursday, December 5, 2013
modernizr JavaScript library: detect mobile, CSS3 and HTML5 features in user browser.
We can use server-side useragent to detect browser type:
Example code to show browser type using useragent
<button onclick="myFunction()">Try it</button>
<script>
function myFunction()
{
document.write(navigator.userAgent);
}
</script>
The userAgent property returns the value of the user-agent header sent by the browser to the server.
But a lot of time, we need to detect the specific features of mobile, CSS3 and HTML5 rather than browser type. modernizr JavaScript library is a client-side script to detect mobile, CSS3 and HTML5 features in user browser. modernizr JS library can be downloaded from:
http://modernizr.com/
To use modernizr JavaScript librar:
<script src="modernizr-1.7.js" type="text/javascript"></script>
test for geolocation feauter
Modernizr.geolocation will return true or false.
test for touch feauture
Modernizr.touch
Test for HTML5 feature
Modernizr.svg
Modernizr.canvas
local storage
Modernizr.localstorage
and more
HTML5 boilerplate:
http://html5boilerplate.com/mobile/
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment