Thursday 08 May 2008 4:28:45 am
Here is how you could do it:
<script language="JavaScript" type="text/javascript">
<!--
if ( window.opera )
document.write( '<link rel="stylesheet" type="text/css" href={"stylesheets/opera.css"|ezdesign} \/>');
else if ( document.all )
document.writeln('<link rel="stylesheet" type="text/css" href={"stylesheets/ie.css"|ezdesign} \/>');
else if ( document.getElementById || document.layers )
document.write( '<link rel="stylesheet" type="text/css" href={"stylesheets/nce.css"|ezdesign} \/>');
//-->
</script>
And here is how you use javascript brackets inside templates:
<script language="JavaScript" type="text/javascript">
<!--
if ( window.opera )
{ldelim}
document.write( '<link rel="stylesheet" type="text/css" href={"stylesheets/opera.css"|ezdesign} \/>');
{rdelim}
else if ( document.all )
{ldelim}
document.writeln('<link rel="stylesheet" type="text/css" href={"stylesheets/ie.css"|ezdesign} \/>');
{rdelim}
else if ( document.getElementById || document.layers )
{ldelim}
document.write( '<link rel="stylesheet" type="text/css" href={"stylesheets/nce.css"|ezdesign} \/>');
{rdelim}
//-->
</script>
But this way of browser sniffing is not very modern, this is how web developer did things 5-10 years ago. Today most web developers tend to code for new browsers, and have extra css that is added for older browsers, witch is mostly internet explorer..
<!-- first include you standard css, then for ie 6 and lower, then ie 7 -->
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href={"stylesheets/ie6.css"|ezdesign} />
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href={"stylesheets/ie7.css"|ezdesign} />
<![endif]-->
eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom
|