Browser detection - IE, Firefox, Safari,
Chrome Many times you require to put in browser-specific HTML / CSS in your files, because most often the pages are rendered differently (esp. IE). You can detect what browser the user is using with the help of PHP. In your PHP file, put the following code first:
And to add, conditional HTML or CSS, put it like this:
Chrome Many times you require to put in browser-specific HTML / CSS in your files, because most often the pages are rendered differently (esp. IE). You can detect what browser the user is using with the help of PHP. In your PHP file, put the following code first:
-
<?php
-
?>
-
<?php
-
//Firefox
-
if ($firefox) {
-
echo 'you are using Firefox!';
-
echo '<br />';
-
}
-
-
// Safari or Chrome. Both use the same engine - webkit
-
if ($safari || $chrome) {
-
echo 'you are using a webkit powered browser';
-
echo '<br />';
-
}
-
-
// IE
-
if ($msie) {
-
echo '<br>you are using Internet Explorer<br>';
-
echo '<br />';
-
}
-
-
// Not IE and for all other browsers
-
if (!$msie) {
-
echo '<br>you are not using Internet Explorer<br>';
-
echo '<br />';
-
}
-
-
// Add inline css
-
if ($firefox) {
-
echo '<style type="text/css">';
-
echo '.mydiv {position:relative; width:100px; height:50px;}';
-
echo '</style>';
-
}
-
?>
No comments:
Post a Comment