how to set the visibility of Label through javascript [Resolved]

Posted by Artisingh30 under JavaScript on 3/28/2011 | Points: 10 | Views : 4432 | Status : [Member] | Replies : 1
hi
I hv compatibility problem with my website so i am using a label which can display the solution.since Problem is occuring with Internat Exploere
so I want if user use IE Browser then that Lable should display otherwise it should not display. i am using this code but it is not working.
<script type="text/javascript">
var browserName=navigator.appName;
if (browserName=="Netscape")
{
document.getElementById("<%=Label19.ClientID%>").style.display ='none';
alert("Hi Netscape User!");
}
else
{
if (browserName=="Microsoft Internet Explorer")
{
alert("Hi, Explorer User!");
}

Please tell me where is problem..???
Thanks and Regards
Arti Singh
else
{
alert("What ARE you browsing with here?");
}
}
</script>




Responses

Posted by: Amitmv76 on: 3/28/2011 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hi,
Try this...


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
function test()
{
var browserName=navigator.appName;
if (browserName=="Microsoft Internet Explorer")
{
document.getElementById("<%=Label19.ClientID%>").style.display ='none';

}


}
</script>
</head>
<body onload="test()">
<form id="form1" runat="server">
<div>
<asp:Label ID="Label19" runat="server" Text="I am Arti Singh "></asp:Label>
</div>
</form>
</body>
</html>

Artisingh30, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response