Hi..
I'm having a problem of redirect my website to use another style sheets for ie and chrome.

This is the way i've done for ie detection :

<!--[if IE 8]>
      <link rel="stylesheet" type="text/css" href="css/ie8.css" />
      <! [endif] -->

and this is the way i've done for chrome detection :

<script type="text/javascript">
      if (navigator.userAgent.toLowerCase().match('chrome')
      document.write('<link rel="stylesheet" type="text/css" href="css/stylechr.css">');
      </script>

but the problem is none of these are working,and i'm in trouble now of fixing the stylesheet for these two browser.
please help,i really dont know what else to do.

Thank You :)

Recommended Answers

All 11 Replies

Try this for IE 8

<!--[if gt IE 7]>
	<link rel="stylesheet" type="text/css" href="css/ie8.css" />
<![endif]-->

AND TRY THIS FOR CHROME

<link rel="stylesheet" href="css/stylechr.css" type="text/chrome" />

Try this for IE 8

<!--[if gt IE 7]>
	<link rel="stylesheet" type="text/css" href="css/ie8.css" />
<![endif]-->

AND TRY THIS FOR CHROME

<link rel="stylesheet" href="css/stylechr.css" type="text/chrome" />

i dont know why...but it is still not working :( help2,please....

Did you link the style sheets correctly? css/ie8.css means that the folder css must be in the same directory as your site, and the file ie8.css must be in the css folder. Same with the chrome one.

yes..i already put it on the right directory and folder.
and this is a new thing that i realised,
when i open my website on the LAN address,i mean like :
http://161.0.1.64/ryzalyusoff.com/public/index.php
my website appear correctly..

but when i open it up using the localhost address which is :
http://localhost/ryzalyusoff.com/public/index.php ,my website appear wrongly.

how could this is being so?now i dont know,wheter the redirection code is not working or something else..
really make me confuse right now..

Your website will appear correctly at the path you defined in your config.php file. If localhost is not defined, it cannot appear there.

As for your original problem:

If you say it appears correctly on your LAN, do you mean in all browsers now, or only in some?

Your website will appear correctly at the path you defined in your config.php file. If localhost is not defined, it cannot appear there.

As for your original problem:

If you say it appears correctly on your LAN, do you mean in all browsers now, or only in some?

nope..by using LAN, it only appear correctly on mozilla and ie only,but not for chrome..

OK, so your IE problem is now sorted out, I gather.

For Chrome, try the full path to the stylesheet and see what happens.

<link rel="stylesheet" href="http://full/url/to/css/stylechr.css" type="text/chrome" />

Also, make sure the code for stylesheet is in the <head></head> section of your file.

Also make sure stylesheet starts with:

The first characters in the css-file should be:

@charset “UTF-8″;

OK, so your IE problem is now sorted out, I gather.

For Chrome, try the full path to the stylesheet and see what happens.

<link rel="stylesheet" href="http://full/url/to/css/stylechr.css" type="text/chrome" />

Also, make sure the code for stylesheet is in the <head></head> section of your file.

Also make sure stylesheet starts with:

The first characters in the css-file should be:

@charset “UTF-8″;

I cannot save the css file with @charset “UTF-8″;
a message pops up said that "it may contain chars that cannot be represented in current encoding."

ok, did you define the exact path now? You may also want to test what happens if you remove the doc type from the html tag at beginning of your file.

If not resolved, please post your chrome style sheet css code, and your index.php html here.

Make Sure that ur Link in the href is placed right. Check my code below if ur using a wordpress CMS :

<script type="text/javascript">
if (navigator.userAgent.toLowerCase().match('chrome'))
document.write('<link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_directory'); ?>/css/stylechr.css" />')
</script>
<link rel="stylesheet" href="css/stylechr.css" type="text/chrome" />

works fine with me , thanx guys

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.