Don't forget to click "Mark as Answer" on the post that helped you. This will give you point and help readers to know which post solved your issue and make their search easy.
Marked as answer by SanjaySutar on Aug 09, 2008 01:33 PM
I just tried using the display attribute with no problems in Internet Explorer 6 and 7 and Firefox 2 and 3.
Now, you might be having an ID problem with "trState". Is that a server-control? Is it in a container? Have you done a View Source and checked what the rendered ID is?
NC...
Marked as answer by SanjaySutar on Aug 09, 2008 01:33 PM
SanjaySutar
Participant
1128 Points
692 Posts
style.display vs style.visibility
Aug 08, 2008 12:23 PM|LINK
Hi i have javascript code as document.getElementById("trState").style.display = 'block';
which works fine in IE, but not working in FireFox.
For FireFox i have to change the code as document.getElementById("trState").style.visibility = 'visible'
kooshal
Member
73 Points
26 Posts
Re: style.display vs style.visibility
Aug 08, 2008 12:58 PM|LINK
Which version of IE and Firefox are u using??
You need to fire the javascript function / code block after the control has been loaded in the page on the browser
Maulik Patel
Contributor
2480 Points
366 Posts
Re: style.display vs style.visibility
Aug 08, 2008 01:24 PM|LINK
Which version of FireFox you use ? because it works fine with FireFox 2.0
See bellow code.
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title></title> <script type=text/javascript> function ShowHide() { if( document.getElementById("mydiv").style.display == 'none') document.getElementById("mydiv").style.display = 'block'; else document.getElementById("mydiv").style.display = 'none'; } </script> </head> <body> <form id="Form1" runat="server"> <input type="button" value="Show/Hide" onclick="ShowHide();" /> <div id="mydiv">data</div> </form> </body> </html>MCTS, Software Engineer
Don't forget to click "Mark as Answer" on the post that helped you. This will give you point and help readers to know which post solved your issue and make their search easy.
gibble
Participant
786 Points
226 Posts
Re: style.display vs style.visibility
Aug 08, 2008 01:32 PM|LINK
Maulik,
You should really change your function to
function ShowHide() { var mydiv = document.getElementById("mydiv"); mydiv.style.display = (mydiv.style.display == 'none') ? 'block' : 'none'; }It will be quicker as it only does the lookup for mydiv in the dom once, not three times.NC01
All-Star
82577 Points
15430 Posts
MVP
Re: style.display vs style.visibility
Aug 08, 2008 01:46 PM|LINK
I just tried using the display attribute with no problems in Internet Explorer 6 and 7 and Firefox 2 and 3.
Now, you might be having an ID problem with "trState". Is that a server-control? Is it in a container? Have you done a View Source and checked what the rendered ID is?
NC...
NHOQUE
Contributor
5103 Points
851 Posts
Re: style.display vs style.visibility
Aug 08, 2008 03:52 PM|LINK
It should work also in FF.
Try with
document.getElementById('<%=trState.ClientID%>').style.display="block";
Thanks.
[n°web]
SanjaySutar
Participant
1128 Points
692 Posts
Re: style.display vs style.visibility
Aug 09, 2008 01:32 PM|LINK
HI all, thanks 4 ur replies.
I am using FireFox 3.
Now the problem is its displaying the content but with distorted output.
and i got the solution for it also.
Simply need to change document.getElementById("trState").style.display = 'block' to document.getElementById("trState").style.display = ''.
i.e don't write any thing inside single quote.
This works fine in IE and FireFox and gives similar output in IE and FireFox.