Forum Moderators: open

Message Too Old, No Replies

can you hide a <div> in ns, but show it in ie?

div tag hiding

         

halfofbob

4:21 am on Apr 4, 2005 (gmt 0)

10+ Year Member



hey, i was wondering if anybody knew of a way to hide a specific <div> from netscape browsers on page load. that's all i need to do.

i have 2 <div> layers set up on my pages and the one is not compatible with netscape browsers... i just wanted to hide it from them, but keep it visible to internet explorer users.

thanks

Bernard Marx

6:33 am on Apr 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How about IE's conditional comments [msdn.microsoft.com]?

dcrombie

8:16 am on Apr 4, 2005 (gmt 0)



Or something like this:

div.hidden { display: none; } 
* html div.hidden { display: block; }

Bernard Marx

10:21 am on Apr 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Good call.

Rambo Tribble

3:24 pm on Apr 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How fares that hack on IE Mac?

dcrombie

3:37 pm on Apr 4, 2005 (gmt 0)



I've used it on a couple of sites and it seems to work fine in both Win and Mac versions of IE ;)

halfofbob

7:19 pm on Apr 4, 2005 (gmt 0)

10+ Year Member



dcrombie,

how do i set this code to work in ns, but not in ie?

div.hidden { display: none; }
* html div.hidden { display: block; }

halfofbob

7:30 pm on Apr 4, 2005 (gmt 0)

10+ Year Member



ok, i can make it work with the conditional comments and the code dcrombie provided. is there a way to disable sounds in a layer? one of my layers has audio embedded in it.

halfofbob

7:50 pm on Apr 4, 2005 (gmt 0)

10+ Year Member



thanks for the help guys, i've got it all figured out.

Bernard Marx

9:09 pm on Apr 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ok, i can make it work with the conditional comments and the code dcrombie provided

I don't think you were meant to use both!

Conditional comments (of that type) are, AFAIK, XML compliant, and work in IE5 & above, while DCrombie's suggestion is a 'hack', relying on an IE 'bug'. That said, it is used quite a lot, and it's neater, easier and probably cooler.

The idea is that only IE considers that the HTML element could have a parent element (the *).

halfofbob

9:35 pm on Apr 4, 2005 (gmt 0)

10+ Year Member



thanks for clearing that up... i was pretty confused.

i took the easy way out, all i did was set the certain <div> tags to hidden.

then i used the conditional comment for ie to show the same <div> tags in ie browsers.

it looks pretty sloppy in the code, but it saved me from having to create 2 individual pages (ie and ns) for each future update.

thanks again for the help.

[edited by: encyclo at 12:33 am (utc) on Oct. 19, 2007]