[thelist] Re: Variable Stylesheets
Cayley Vos
cvos at netpaths.net
Mon Dec 3 06:22:56 CST 2001
This is a PHP script I use to generate conditional stylesheets & DTD
headers based on user agent. All you have to do is create specific
(external) stylesheets based on browsers. This is setup for the 4 major
types:
IE/NN on Mac/Win platforms
Feel free to use and enjoy!
/* begin DTD header creation */
function _brfind($component){
global $HTTP_USER_AGENT;
$result = stristr($HTTP_USER_AGENT,$component);
return $result;
}
function get_doctype(){
if ( $this->_brfind('MSIE 4') or $this->_brfind('MSIE 5') ) {
if ( $this->_brfind('Mac') ) {
$style = ( $this->_brfind('MSIE 5') ) ? '<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">':'stylemac.css';
} elseif ( $this->_brfind('Win') ) {
$style = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN">';
}
} elseif ( !$this->_brfind('MSIE') ) {
if ( $this->_brfind('Mozilla/5') or $this->_brfind('Mozilla/6') ) {
$style = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN"
"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">';
} elseif ( $this->_brfind('Mozilla/4') ) {
if ( $this->_brfind('Mac') ) {
$style = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2
Final//EN">';
} elseif ( $this->_brfind('Win') ) {
$style = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN">';
} else {
$style = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN">';
}
}
}
return $style;
}
/*end DTD header creation */
--
Cayley Vos, Principal
360.714.8395 office
360.223.7799 cell
http://NetPaths.net
____________________________________________
web site design | programming | search engine marketing
More information about the thelist
mailing list