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

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 = "";
	}
}

3 thoughts on “IE: Could not get the visibility property. Invalid argument.

  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…

  2. i came across this problem. but it was solved.
    u have to write the code:

    dateTable.style.display = ‘ ‘;

    only in single quotes not double quotes.
    this change when applies to my code works in all browsers

  3. I don know how to fix this issue as the js is residing in the openfaces jar
    Is there any common solution for open faces table.js where they ve used “visibility” property ?

Leave a Reply