December 11, 200916 yr I am working on a site that uses a mac font throughout (helvetica neue ultralight) and I'm looking for a way to target any pc with css or html or whatever and redirect to a seperate page or get up a seperate css file. Similar to the target ie code: <!--[if ie]> code <![endif]--> Is this possible?
December 11, 200916 yr Not directly, as far as I know. You can only do it by putting the mac font first and then a websafe font so that PCs ignore the mac font and show the websafe font. body { font-family: "helvetica neue ultralight", arial, monospace; line-height: 1.3; color: #335500; background-color: #e9e9e2; font-size: small; } See http://www.ampsoft.net/webdesign-l/WindowsMacFonts.html for browser-safe fonts.
December 11, 200916 yr Author yeah ive done that, the site works in IE but i just want it to rediredct to a seperate page.
December 11, 200916 yr easily done. The following will redirect all i.e users to a page of your choosing. <!--[if IE]> <meta http-equiv="refresh" content="0; url=/yourpage.html" /> <script type="text/javascript"> /* <![CDATA[ */ window.top.location = '/yourpage.html'; /* ]]> */ </script> <![endif]--> This is mega overkill for a font issue, I agree with wickham about font stacks. The above would be useful if you didn't want to support ie6 and wanted to redirect them to a page to download firefox or something.
December 11, 200916 yr Author yes, i already have code that redirects IE users, i want to target pc users though, and redirect to a completely different page
December 11, 200916 yr Oh I see. The short answer is no, this can not be done with (x)html/css. Need javascript for that.
December 12, 200916 yr Author ok i found this: // This script sets OSName variable as follows: // "Windows" for all versions of Windows // "MacOS" for all versions of Macintosh OS // "Linux" for all versions of Linux // "UNIX" for all other UNIX flavors // "Unknown OS" indicates failure to detect the OS var OSName="Unknown OS"; if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows"; if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS"; if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX"; if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux"; document.write('Your OS: '+OSName); this will detect and display the OS, how would i alter it so that, instead of displaying the os name, it redirects and result other than 'MacOS' to a seperate page?
December 12, 200916 yr Well done; however my javascript is extremely limited, but in the document.write you may be able to write code to redirect (Note, I read somewhere that document.write is out of date javascript, but I don't know what the modern script is and document.write still works). <meta http-equiv="refresh" content="0; url=page2.html"/> is redirect code that normally goes in the head section to redirect to another url so try with trial and error to put that in a document.write; when the browser reaches the meta refresh it may process it instead of displaying it as text. However, I'm sure there's a substitute for document.write to tell a browser to action the code. My advice would be to have only the Windows option if that is what you are trying to target. var OSName="Unknown OS"; if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows"; document.write('<meta http-equiv="refresh" content="0; url=page2.html"/>'); That's just a guess, I've no idea if it works. You may have to put in \ before every " in the meta refresh which is required for PHP to disable the " which carries instructions but may not be required for javascript. Good luck. You might get a proper answer on the Javascript board.
December 12, 200916 yr Author hmm, when i use that code it seems to just process the <meta http-equiv="refresh" content="0; url=page2.html"/> part and redirects my mac to the alternate page. my javascript is almost certainly worse than your so i cant even really do trial and error stuff, i need it spelled out for me. thanks for the help though! feel like im getting there.
December 12, 200916 yr I'm confused about this sequence !=-1 where ! means NOT and the -1 means true or false, but 0 is usually false and 1 is true, so I would expect the code to be =1 so that if true, it processes the document.write; at least that would happen in PHP.
December 12, 200916 yr Why not just use @fontface so that many major browsers will use that font? http://blog.themeforest.net/tutorials/css-font-face-and-15-free-fonts-you-can-use-today/
December 12, 200916 yr Instead of using the appVersion property, use the platform property and just use window.location to redirect. For non macs: <script type="text/javascript"> if (navigator.platform.indexOf("Mac") == -1) { window.location = 'otherpage.html'; } </script> As for the '-1', that is returned by the indexOf method when no match is found. hth
December 12, 200916 yr Author Haha brilliant! Thankyou. Anyone care to test it? http://philxthomas.com/
December 14, 200916 yr Author nahh just to annoy people who want websites to be available to everyone.
Create an account or sign in to comment