my2cents

28. April, 2008

IE: Could not get the visibility property. Invalid argument.

Filed under: Web Authoring — frightanic @ 22:55

This blog now resides at http://www.frightanic.com/. It will be discontinued here…

Microsoft’s Internet Explorer never fails to amaze me – coding JavaScript and CSS for the IE is quite a challenge. The other day I tried to show/hide a table based on the value of a dropdown box.

function hideUnhideDateFields() {
	var tarifScheme = document.getElementById("dropdownTarifscheme");
	var dateTable = document.getElementById("dateTable");
	if (tarifScheme && tarifScheme.value == "") {
		dateTable.style.visibility = "collapse";
	} else {
		dateTable.style.visibility = "visible";
	}
}

While this works flawlessly with browsers, the script crashes in IE: it complains about “Could not get the visibility property. Invalid argument.” Hey IE, talk to me, what is your problem?
I couldn’t get behind it and switched stratey, therefore.

function hideUnhideDateFields() {
	var tarifScheme = document.getElementById("dropdownTarifscheme");
	var dateTable = document.getElementById("dateTable");
	if (tarifScheme && tarifScheme.value == "") {
		dateTable.style.display = "none";
	} else {
		dateTable.style.display = "";
	}
}
Advertisements

6 Comments

  1. Ran into this very same problem whilst coding my own collapsin menu system. Have had to write two separate sets of code, one for IE and one for non-IE… Not yet got it to work fully, everytime I refresh the page and see it failing in IE it reminds me of one of the reasons why I left this awful browser behind and can’t understand why others swear by it…

    Comment by ChrisP — 23. February, 2009 @ 00:18

  2. I ran into the same problem. But when I set the visibility property while defining the element, it worked.
    For e.g. Hello

    Then, you can set the visibility for the element. The difference between visibility and display is that visibility will just hide it without collapsing the space.

    Comment by Vishal — 10. November, 2009 @ 19:35

  3. Ok. WordPress collapsed my example.

    style = “visibility:visible” for the element you want to use the visibility property

    Comment by Vishal — 10. November, 2009 @ 19:36

  4. IE is really a f…..uck browser

    Comment by faisal — 10. March, 2011 @ 13:41

  5. Top tip mate.. solved an infuriating problem I was having.

    Comment by Rob — 30. March, 2011 @ 21:43

  6. How come you dont have your website viewable in mobile format? cant view anything in my Droid.

    Comment by halls for hire hampshire — 26. June, 2012 @ 14:33


RSS feed for comments on this post.

Create a free website or blog at WordPress.com.

%d bloggers like this: