Extending link area using DOM methods | Ryan Joy (atxryan) Extending link area using DOM methods | Web developer living and playing in Austin, Texas. Microsoft Developer Evangelist.
RSS Feed

Extending link area using DOM methods

Comments Off on Extending link area using DOM methods

January 20, 2007 by Ryan Joy


function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function linkTabs() {
  if(!document.getElementById("top_tabs")) return false;

  var topTabs = document.getElementById("top_tabs");
  var topTabsLi = topTabs.getElementsByTagName("li");

  for (var i = 0; i < topTabsLi.length; i++) {
    topTabsLi[i].onmouseover = function() {
      this.style.cursor = "pointer";
    }
    topTabsLi[i].onclick = function() {
      return linkThis(this);
    }
  }
}
function linkThis(whichLink) {
  window.location = whichLink.getElementsByTagName("a")[0].getAttribute("href");
}

addLoadEvent(linkTabs);

Comments Off on Extending link area using DOM methods

Sorry, comments are closed.

Archives: