Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hiding DIVS, IE

Status
Not open for further replies.

skiflyer

Programmer
Sep 24, 2002
2,213
US
Here's a question, why does IE suck so much?

ugh... embarassingly delivered a web site prototype today which I hadn't re-tested in IE.

I am re-using code that has worked in IE before... but now it's not... it basically hide's and show's DIVS... so the user clicks a button, it will show a given div, then hide the one that contained the button. The code looks like this.

Code:
var browserType;

if (document.layers) {browserType = "nn4"}
if (document.all) {browserType = "ie"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {browserType= "gecko"}


function hide(which_div) {
  alert(browserType);

  if (browserType == "gecko" )
    {
       document.poppedLayer = eval('document.getElementById(\'' + which_div + '\')');
    }
    else if (browserType == "ie")
    {
       document.poppedLayer = eval('document.all[\'' + which_div + '\']');
    }
    else
    {
       document.poppedLayer = eval('document.layers[\'`' + which_div + '\']');
    }

  document.poppedLayer.style.display = "none";
}

function show(which_div) {
  if (browserType == "gecko" )
    {
       document.poppedLayer = eval('document.getElementById(\'' + which_div + '\')');
    }
    else if (browserType == "ie")
    {
       document.poppedLayer = eval('document.all[\'' + which_div + '\']');
    }
    else
    {
       document.poppedLayer = eval('document.layers[\'`' + which_div + '\']');
    }

  document.poppedLayer.style.display = "block";

}

And works great in Firebird, but blanks out the whole screen in IE. IE Also doesn't let me debug my javascript, so I'm lost. Does anyone see anything obvious with the code that would cause it to choke?

-Rob
 
mutter... ok, I figured it out... DIV id's in IE can't start with a number or it destroys the whole page. Doesn't disable it or anything kind like that, just screws the whole thing up.

Who's brilliant idea was that?

Well, for people to know for the future... don't start your div names with a number in IE.

-Rob
 
There is an integrated debugger you can download from the M$ site for IE.

Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top