Below code for Display Browser Version and Type
<?php
jimport('joomla.environment.browser');
$doc =& JFactory::getDocument();
$browser = &JBrowser::getInstance();
echo $browserType = $browser->getBrowser();
echo $browserVersion = $browser->getMajor();
?>
Output in IE
Internet Explorer6 - msie6
Internet Explorer7 - msie7
Internet Explorer8 - msie8
Output in Mozilla Firefox
Mozilla Firefox - mozilla5
Output in Google Chrome
Mozilla Firefox - konqueror535
Output in Safari
Mozilla Firefox - konqueror534
Below code for Add CSS file to browser version less than IE 7
<?php
jimport('joomla.environment.browser');
$doc =& JFactory::getDocument();
$browser = &JBrowser::getInstance();
$browserType = $browser->getBrowser();
$browserVersion = $browser->getMajor();
if(($browserType == 'msie') && ($browserVersion < 7))
{
$doc->addStyleSheet( 'css/ie6.css' );
}
?>
No comments:
Post a Comment