Jump to content

Is Function Order Relevant?


chibineku

Recommended Posts

I have a few scripts that run onload and I have noticed that since I added a new function that runs, one of the ones that worked previously only works on FF. Is order important? I have a function called prep() that runs my other onload functions...do I need to return values at the end of these functions so their operation will continue? Here is my whole script file:Note that setCurPage has the clickmenu function nestled inside it, because for some reason unknown to man or beast, this was the only way to get it to work:

<script type="text/javascript">function prep() {  setCurPage();  breadcrumb();			colHeight();}var CurRaw;var Cur;function setCurPage() {var CurPage = "<?php echo $_SERVER["PHP_SELF"]; ?>";CurRaw = CurPage.substr(1);Cur = CurRaw.split(".")[0];if(document.getElementById(Cur)) {var oldNode = document.getElementById(Cur);var newNode = document.createElement("li");newNode.id = "cur";newNode.className = "sub unclick";var innards = oldNode.children;while(innards.length > 0) {newNode.appendChild(innards[0]);}var innardsContent = oldNode.innerHTML;newNode.innerHTML = innardsContent;oldNode.parentNode.replaceChild(newNode, oldNode);}  clickMenu('menu');}function checkChars(el) {  el.value = el.value.replace(/[^a-zA-Z0-9 -]/g, "");}function checkCharsEmail(email) {  email.value = email.value.replace(/[^a-zA-Z0-9@_.-]/g, "");}function checkCharsUsername(username) {  username.value = username.value.replace(/[^a-zA-Z0-9_.-]/g, "");}clickMenu = function(menu) { var getEls = document.getElementById(menu).getElementsByTagName("LI"); var getAgn = getEls; for (var i=0; i<getEls.length; i++) { getEls[i].onclick=function() { for (var x=0; x<getAgn.length; x++) { getAgn[x].className=getAgn[x].className.replace("unclick", ""); getAgn[x].className=getAgn[x].className.replace("click", "unclick"); } if ((this.className.indexOf('unclick'))!=-1) { this.className=this.className.replace("unclick", "");; } else { this.className+=" click"; } } } }  function breadcrumb() {   var trail = document.getElementById("breadcrumb");   trail.innerHTML += "><a href=\""+CurRaw+">"+Cur+"\<\/a>"; }  function colHeight() {   var footer = document.getElementById("footer");   var center = document.getElementById("center");   var height = parseInt(center.offsetHeight);   var left = document.getElementById("left");   var right = document.getElementById("right");   left.style.height = height+"px";   right.style.height = height+"px"; } </script>

So, do I need to return something, do I need to nest the next function in the sequence inside the one that runs previously, or what? Mozilla, as I said, handles it fine as is.

Link to comment
Share on other sites

try changing: trail.innerHTML += "><a href=\""+CurRaw+">"+Cur+"\<\/a>";to trail.innerHTML += "><a href=\""+CurRaw+"\">"+Cur+"</a>";you might want to add if(height < left.offsetHeight) { height=left.offsetHeight; } if(height < right.offsetHeight) { height=right.offsetHeight; }which compares height of the centre column to left and right and adjust if required

Link to comment
Share on other sites

try changing: trail.innerHTML += "><a href=\""+CurRaw+">"+Cur+"\<\/a>";to trail.innerHTML += "><a href=\""+CurRaw+"\">"+Cur+"</a>";
You beautiful coder, you!
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...