Results 1 to 3 of 3

Thread: Disable the link of page you are in

  1. #1
    Join Date
    Apr 2008

    Disable the link of page you are in

    I am trying to find a code that will disable the link that I am in but I cannot get the exact phrase to search for it. What I am doing is, if I am at homepage, the link "home" should not have link and same with other pages if I am there. I want to do it with javascript code. Is it possible?

  2. #2
    Join Date
    May 2007
    Cleveland, OH
    There might be better ways to do this, but this method should do the trick.
    //array of all the links on the page
    var links = document.getElementsByTagName("a");
    //loop through the array
    for (var link in links) {
      //if the href attribute points to this page
      if (link.href == window.location.href) {
        //add an onclick event that returns false (prevents link from being followed)
        link.onclick = function() { return false;}

  3. #3
    Join Date
    Apr 2008
    Thank You. I will try to check it out.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center