/    Sign up×
Community /Pin to ProfileBookmark

Hey, we all kn ow that IE and firefox are different. Looks good in FF, but not in IE.

How can I make it so that, if the user is viewing a site in IE, it will use a ‘fix’ to use the patch. Like, if the positioning on FF is:

[CODE]
position: relative; margin-top:10px; margin-left:10px;
[/CODE]

and if the user views in IE, it will use the patch:

[CODE]
position: relative; margin-top:5px; margin-left:30px;
[/CODE]

How can I do this?

Note: I made up those codes, just so you know.

Thanks, Cody

to post a comment
HTML

5 Comments(s)

Copy linkTweet thisAlerts:
@welshFeb 12.2006 — [code=html]
<HEAD>
<SCRIPT language="JavaScript">
<!--
var browserName=navigator.appName;
if (browserName=="Netscape")
{
alert("Hi Netscape User!");
}
else
{
if (browserName=="Microsoft Internet Explorer")
{
alert("Hi, Explorer User!");
}
else
{
alert("What ARE you browsing with here?");
}
}
//-->
</SCRIPT>
</HEAD>
[/code]

not sure if thats the most reliable script it showed me using netscape and im on firefox. You can combined this from something from google search: http://www.google.ca/search?hl=en&q=javascript+change+style+sheet&btnG=Google+Search&meta= to change the stylesheet depending on the browser.
Copy linkTweet thisAlerts:
@Jeff_MottFeb 12.2006 — IE also includes conditional comments, which you can use.

[i]<!--[if IE]>



...stuff...



<![endif]-->[/i]
Copy linkTweet thisAlerts:
@KravvitzFeb 12.2006 — Don't use JavaScript for that.

As Jeff suggested, it's best to use conditional comments to give IE/Win a special stylesheet.

[url=http://msdn.microsoft.com/workshop/author/dhtml/overview/ccomment_ovw.asp]About Conditional Comments[/url]

[url=http://www.positioniseverything.net/articles/multiIE.html]Some more information on conditional comments can be found on this page.[/url]

[url=http://www.quirksmode.org/css/condcom.html]QuirksMode.org : Conditional comments[/url]

http://www.google.com/search?q=IE+conditional+comment
Copy linkTweet thisAlerts:
@codym43authorFeb 12.2006 — Do I have to include a totally different stylesheet, in order to make it compatible?

Also, This page isn't centered. I tried the following:

[CODE]
#container {
margin-left: 1%;
margin-right: 1%;
}
[/CODE]


If I change it to 10%, it doesn't look right in 800*600 resolutions, In IE, you have to scroll, and in FF you do also but you cant go all the way. Help?
Copy linkTweet thisAlerts:
@KravvitzFeb 12.2006 — To use conditional comments you would add an additional stylesheet and put it in a style element or link to it with a link element either of which would be inside the condional comment.

[url=http://www.dynamicsitesolutions.com/css/center_element/]How to Center Elements with CSS (in IE5+/Win and other browsers)[/url]
×

Success!

Help @codym43 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...