Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

X-Browser: Setting CSS for OS/Brows/Vers

Status
Not open for further replies.

cmdhtml

Programmer
Nov 25, 2001
2
US
Hello,

I'm learning cross-browser positioning and trying to apply it to the following web page:

The page consists of three tables stacked on top of each other and I am positioning the elements in the center table. I'm using the Ultimate Browser Sniffer (
I thought the easiest way would be to have a Javascript that calls different stylesheets depending on the platform/browser/version. I'm hoping someone will have the answer to 2 questions that might help me figure this out.

1) The javascript I wrote to call different stylesheets depending on the variables set up in the sniffer isn't working. It only calls the final statement (else) no matter what browser I'm testing in. Any ideas why?

2) Also, I initially tried to write this javascript to check more than one variable to determine which stylesheet to serve. This didn't work, so I'm wondering if my syntax is correct, or if I'm just writing it incorrectly. Here's what I wrote:

<link href=&quot;macie5up.css&quot; rel=&quot;styleSheet&quot; type=&quot;text/css&quot;>

<script language=&quot;JavaScript&quot;>
<!--

if ((is_macppc) && (is_ie5up))
{
document.write('<link href=&quot;macie5up.css&quot; rel=&quot;styleSheet&quot; type=&quot;text/css&quot;>'); }

else if ((is_macppc) && (is_nav4up))
{
document.write('<link href=&quot;macns4up.css&quot; rel=&quot;styleSheet&quot; type=&quot;text/css&quot;>'); }

else ((is_macppc) && (is_gecko))
{
document.write('<link href=&quot;macgecko.css&quot; rel=&quot;styleSheet&quot; type=&quot;text/css&quot;>'); }
-->
</script>

I'm hoping to get this to work in all IE and NS browsers 4 and up on Macs and PCs.

Thanks for any help!

cmdhtml
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top