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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

style property in IE6

Status
Not open for further replies.

kjmaclean

Technical User
Feb 21, 2009
14
US
I use this code to dynamically change the visibility of a div:
Code:
  document.getElementById('div_id').style.display="block";
document.all.div_id.style.display = "block"; // for IE 6


The first code statement works great in all browsers (including IE7+) but not in IE6, so I added the second statement, but no joy.

Any suggestions on getting the style property to work in IE6?

Probably no one should support that crap browser anyway, but I'm stubborn.

Thanks in advance for any enlightenment.
 
Thanks feherke, I thought that IE 6 supported the style property and getElementById, so now I can look for my error elsewhere.
I'd post the JS code but there's way too much of it!
 
I changed my mind. Here's the relevant code, maybe I did something wrong:

markup:

Code:
  <a id="images_button" class="SetMeter" href="#gs_imgs"></a>

and then the select in the form:
Code:
<form id="img_list">
<select id="gasom_images">
<option value="">Change Images</option>
<option value="">No Image</option>
...more options...
</select>
</form>

the href is just an anchor on the page that moves the user to a select drop-down box. I use a CSS background image and hover image to get the rollover effect on the button

Here's the CSS:
Code:
select#gasom_images {display: none;}

here's the JS:

Code:
addEvent (document.getElementById('images_button'), 'click', visibleSelect);

I use Scott Andrew's addEvent and removeEvent func's

and then the func:

Code:
function visibleSelect()
{
document.getElementById('gasom_images').style.display="block";
}

The CSS hides the drop down and the images_button displays it.
Works great in everything except IE 6
 
Hi

And when is [tt]addEvent()[/tt] called ? Should be called after the document is loaded. This way works for me in Explorer 6 :
Code:
[red]window.onload=function() {[/red]
  addEvent (document.getElementById('images_button'), 'click', visibleSelect);
[red]}[/red]

Feherke.
 
OK I solved the problem.
It wasn't with the JS at all, but the fact that IE 6 displayed the select box underneath another image. Duh.

I simply adjusted the CSS of the select box in IE 6 and everything is fine.

Thanks feherke for pointing out that it should work in IE6, that saved me a lot of time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top