Specific BrowsersDespite all your careful template coding sometimes a particular browser doesn't play safe with a particular extension. Conditional stylesheets can be a useful solution to load CSS for a particular version of IE but if you want HTML to be conditionally loaded you may run into problems with browsers other than IE.

 

Use the following code to detect if the viewer is using IE, Firefox, Chrome or some other browser.

 

<?php
$br = strtolower($_SERVER['HTTP_USER_AGENT']);

if(ereg("msie", $br)) {echo 'You are using IE';}
elseif(ereg("firefox", $br)) {echo 'You are using Firefox';}
elseif(ereg("chrome", $br)) {echo '<You are using Chrome';}
else {echo 'You are using something other than IE, Firefox or Chrome.';}
?>

 

This merely outputs some text but can be easily manipulated to output module positions. The below code outputs a module position called either "ie", "firefox", "chrome" or "other", depending on the browser type.

 

 

<?php
$br = strtolower($_SERVER['HTTP_USER_AGENT']);
if(ereg("msie", $br)) {echo '<jdoc:include type="modules" name="ie"/>';} <br />

elseif(ereg("firefox", $br)) {echo '<jdoc:include type="modules" name="firefox"/>';}<br />

elseif(ereg("chrome", $br)) {echo '<jdoc:include type="modules" name="chrome"/>';}<br />

else {echo '<jdoc:include type="modules" name="other"/>';}

?>

 

Hyde-Design 5/5 based on 625 0 5 customer reviews