how can I get the name of the browser ( I'm interested in getting IE7 because it creates problems for me) by using javascript?
Reason why I want a browser name so I can assign class to one of my footer elements which doesn't look good in IE7.
I want to do this on page load, #1 check browser name , 2# if IE 7 assign class to element else do nothing. Is this the right approach by the way ? thank you
UPDATE
I have HTML something like this
<div id="some_div">
some content
</div>
Can I use IE conditional ments and how? obviously if I put another div in front or below this div which appears only in IE both divs will appear in IE7 then.
how can I get the name of the browser ( I'm interested in getting IE7 because it creates problems for me) by using javascript?
Reason why I want a browser name so I can assign class to one of my footer elements which doesn't look good in IE7.
I want to do this on page load, #1 check browser name , 2# if IE 7 assign class to element else do nothing. Is this the right approach by the way ? thank you
UPDATE
I have HTML something like this
<div id="some_div">
some content
</div>
Can I use IE conditional ments and how? obviously if I put another div in front or below this div which appears only in IE both divs will appear in IE7 then.
Share Improve this question edited Dec 9, 2009 at 14:03 Gandalf StormCrow asked Dec 9, 2009 at 13:58 Gandalf StormCrowGandalf StormCrow 26.2k71 gold badges179 silver badges268 bronze badges3 Answers
Reset to default 5Don't do this with JavaScript, do it with a conditional ment:
<!--[if IE 7]>
... some code only for IE 7
<![endif]-->
While you can't really alter your page structure in such conditional ments the canonical way to use them is simply to include an additional stylesheet with fixes in your <head>
:
#footer {
/* fixes here */
}
<!--[if IE 7]>
<script type="text/javascript">IE7=true;</script>
<![endif]-->
<script type="text/javascript">
if (IE7) {
/* do fancy error correction here... */
}
</script>
Another link about conditional ments.
Html markup
<!--[if IE 7]><html class="ie7"><![endif]-->
<!--[if IE 8]><html class="ie8"><![endif]-->
<!--[if gt IE 8]><!--><html class=""><!--<![endif]-->
CSS
#some_div {
/* normal css */
}
/*below css will be applied only for IE7*/
.ie7 #some_div {
/* your css for IE7 goes here */
}
you may find more useful info http://www.paulirish./2008/conditional-stylesheets-vs-css-hacks-answer-neither/ here
Hope this helps.