It works in Chrome and Firefox, but not in IE
The only thing that does not work is when i click it, it dosen't unhide or change the title, so basically, function unHide is not running, although there are no errors thrown.
I have this in the top of the page
document.getElementsByClassName = function(className){
var hasClassName = new RegExp("(?:^|\\s)" + className + "(?:$|\\s)");
var allElements = document.getElementsByTagName("*");
var results = [];
var element;
for (var i = 0; (element = allElements[i]) != null; i++) {
var elementClass = element.className;
if (elementClass && elementClass.indexOf(className) != -1 && hasClassName.test(elementClass))
results.push(element);
}
return results;
}
function hider(){
var eles = document.getElementsByClassName('hider');
for(var i = 0; i < eles.length; i++){
var theid = eles[i].id;
eles[i].innerHTML = "<div style='display:block; text-decoration:none; color: black; clear:both; text-align:right; float:right; margin-top:-40px; margin-right:3px;' class='open'><a href='#' onclick=\"unHide('" + theid + "'); return false\" > Click To Open </a></div><div class='hides'> " + eles[i].innerHTML + "</div>";
}
}
function unHide(a){
var eles = document.getElementById(a);
str = eles.innerHTML;
if(str.search("> Click To Open <") == -1){
str = str.replace("> Click To Close <", "> Click To Open <");
str = str.replace("class=\"nothides\"", "class=\"hides\"");
}
else{
str = str.replace("> Click To Open <", "> Click To Close <");
str = str.replace("class=\"hides\"", "class=\"nothides\"");
}
eles.innerHTML = str;
}
and i have this where i want it to display and hide the section
<h4 onclick="unHide('editB')">Edit This Property</h4>
<div id='editB' class='hider'>
...
</div>
The way it works is that it reads the page for all objects with the class name "hider"
then it inserts two divs into "hider", one of them is a title that says: "click to open" and the other div has a class of "hides" that is set to display:none
Once "click to open" is clicked, it uses .replace to find "click to open" and class=hide and change them to "Click to Close" and class=nothides
if it is clicked again, it does the opposite.
i just need to know why it isn't working in IE.
Thanks in advance

New Topic/Question
Reply



MultiQuote







|