views:

258

answers:

2

Hi , i am a newbie C# Programmer. I have a problem in xhtml. I want to check that if browser is IE6 or not. For example if ie6 then div id="div1" style="display:block;" else div id="div1" style="display:none;"> How can i control my browser and use if clause in xhtml?

+1  A: 

Assign to your div one permanent style:

<div id="div1" class="jumping-div"></div>

Define the default style:

style1.css:

div.jumping-div
{
    display:none;
}

Then create another stylesheet which will redefine the class:

style2.css:

div.jumping-div
{
    display:block;
}

Then using conditional checks you can include another stylesheet:

<link href="style1.css" rel="Stylesheet" type="text/css" />

<!--[if IE 6]>
    <link href="style1.css" rel="Stylesheet" type="text/css" />
<![endif]-->
Developer Art
i know this but this is not what i am looking for, i have to use "else" statement too?
Mehmet Kaleli
I'm afraid there is no "else" part. Check the specs: http://msdn.microsoft.com/en-us/library/ms537512%28VS.85%29.aspx
Developer Art
A: 

conditional comments are easiest, you can also do it server side...

<% if (HttpContext.Request.UserAgent.Contains("internet explorer 6")) //Not sure what the exact name is, need to look it up.
{%>
   //HTML
<%}%>
Paul Creasey
This worked Paul, Thanks :)
Mehmet Kaleli