A JavaScript class for checking browser & mobile compatibility.
- Browser Info
- Detect the current browser name. For example Chrome.
- Detect the current browser version to no decimal places. For example Chrome 10.
- Detect the current latest browser version. For example Chrome 10.0.167.
- Detect the current application name. For example Netscape.
- Detect current orientation of the browser window.
- Mobile Detection
- Detect whether the current browser is a mobile browser.
- Detect a change in orientation and provide a callback function. For example when some one rotates their iPhone into portrait view you can create a callback telling them to rotate into landscape.
The WebVC.browser(); method allows you get current browser information.
- Browser Name:
WebVC.browser().name - Browser Major Version:
WebVC.browser().version - Browser Current Version:
WebVC.browser().version_accurate - Browser Application Name:
WebVC.browser().app_name
Use WebVC.is_mobile() to detect mobile browsers.
if ( WebVC.is_mobile() )
{
alert( "Mobile Browser Present!" );
}
Use WebVC.orientation() to detect the current orientation.
alert( WebVC.orientation() );
Use WebVC.mobile_orientation() to detect the current orientation.
alert( WebVC.mobile_orientation() );
Use WebVC.mobile_orientation_change( function_name ) to detect a change in orientation.
Parameters: function_name - The name of the callback function when a change of orientation has been detected.
function alertCurrentOrientation ()
{
alert( WebVC.mobile_orientation() );
}
WebVC.mobile_orientation_change( alertCurrentOrientation );
Thanks for reading!