Forum Moderators: open
<script language="JavaScript" type="text/javascript">
function getElementsByClass(searchClass,node,tag) {
var classElements = new Array();
if ( node == null )
node = document;
if ( tag == null )
tag = '*';
var els = node.getElementsByTagName(tag);
var elsLen = els.length;var pattern = new RegExp("(^¦\\s)"+searchClass+"(\\s¦$)");
for (i = 0, j = 0; i < elsLen; i++) {
if ( pattern.test(els[i].className) ) {
classElements[j] = els[i];
j++;
}
}
return classElements;
}
function show_bar(ev,nom) {
MouseX = ev.clientX + document.body.scrollLeft;
MouseY = ev.clientY + document.body.scrollTop;
obj = document.getElementById(nom);
obj.style.top = MouseY + 10-document.getElementByClass("wrap").offsetParent.offsetTop-40+"px";
obj.style.left = MouseX-document.getElementByClass("wrap").offsetParent.offsetLeft+"px";
obj.style.visibility = "visible";
}function hide_bar(nom) {document.getElementByClass(nom).style.visibility="hidden"}</script>
webpage:
<snip>
so when I click on a nickname in one of 3 tables nothing happens.
The second problem, there is a gigant space after layout caused by this js, is it possible to avoid it?
Could somebody help me with that?
Thank you
[edited by: eelixduppy at 8:19 am (utc) on Jan. 25, 2009]
[edit reason] no personal URLs, please [/edit]
function show_bar(ev,nom) {
MouseX = ev.clientX + document.body.scrollLeft;
MouseY = ev.clientY + document.body.scrollTop;
obj = document.getElementById(nom);
obj.style.top = MouseY + 10-document.getElementByClass("wrap").offsetParent.offsetTop-40+"px";
obj.style.left = MouseX-document.getElementByClass("wrap").offsetParent.offsetLeft+"px";
obj.style.visibility = "visible";}function hide_bar(nom) {document.getElementByClass(nom).style.visibility="hidden"}
I assume they both should be the same, that is ById or ByClass.
Also the function you show is getElementsByClass, perhaps all calls to getElementByClass should be changed to getElementById or at least getElementsByClass()[0]