I have next link:
<a id="HeaderImage1Tab" style="display: block;" onclick="HeaderImage1Tab(this);" href="javascript:void(0)">- Header Image 1</a>
clicking this link call next js code:
function HeaderImage1Tab(link) {
if (link.innerText == "+ Header Image 1") {
document.getElementById("HeaderImage1Table").style.display = 'block';
link.innerText = "- Header Image 1";
} else {
document.getElementById("HeaderImage1Table").style.display = 'none';
link.innerText = "+ Header Image 1";
}
}
Basically what it does is just showing/hiding table block below link. All works in every browser except Firefox. In Firefox I need to double click on link for code to fire and to see table block. And whats weird is that I need to double click only first time, and after it is working as expected.
Update #1: I'm working on asp.net site. I also have around 15 links like I mention above on the same page.
Solved
Update #2: Using textContent
instead of innerText
solve the problem. Appears that Firefox does not support inner text
.
Update #3: This JS snipped fix issue of textContent
in IE8 and older:
if (Object.defineProperty && Object.getOwnPropertyDescriptor &&
Object.getOwnPropertyDescriptor(Element.prototype, "textContent") &&
!Object.getOwnPropertyDescriptor(Element.prototype, "textContent").get)
(function() {
var innerText = Object.getOwnPropertyDescriptor(Element.prototype, "innerText");
Object.defineProperty(Element.prototype, "textContent",
{
get : function() {
return innerText.get.call(this)
},
set : function(x) {
return innerText.set.call(this, x)
}
}
);
})();