Web Analytics Made Easy -
StatCounter Search for a particular part of page, and hide it - Please Help - CodingForum

Announcement

Collapse
No announcement yet.

Search for a particular part of page, and hide it - Please Help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Search for a particular part of page, and hide it - Please Help

    Hi all,
    I'm using a buggy plugin in joomla, and it generates a table of contents twice in IE6. That table should be shown only once in the page. I can't find the reason why is this happening and fix it.

    I thought that maybe searching this table inside document, via javascript, and making it non visible would be a terrible but possibly ok solution.

    This is a possible generated table:

    <table id='sobi2CatListSymbols'>
    ....code inside table in not static, it changes from page to page....
    </table>

    1) Can I somehow search for the second occurrence of it in the document and make it non visible?
    2) Are there kind of regular expressions for searching it and replacing it with an empty string?

    I really need help in this so any reply would be very welcome and helpfull.
    Last edited by ktsixit; Apr 16, 2009, 05:02 AM.

  • #2
    You can eliminate duplicates with
    Code:
    eliminateDuplicateId(id){ // keeps the first element with a given id, discards all others
      var el=document.getElementById(id);
      if(!el) return;
      var ns=el.nextSibling;
      var par=el.parentNode;
      par.removeChild(el); // detach temporarily
      var more;
      while(more = document.getElementById(id)){ // yes I meant = and not ==
         more.parentNode.removeChild(more);
      }
      // reattach our element
      if(ns){
        par.insertBefore(el,ns);
      }
      else{
        parent.appendChild(el);
      }
    }
    But you really ought to get the plugin fixed.

    Comment


    • #3
      Thank you very much for your reply. I tried the code but unfortunately it didn't work properly. This is what I've done

      Code:
      <head>
      <script type="text/javascript">
      function eliminateDuplicateId(id){ // keeps the first element with a given id, discards all others
        var el=document.getElementById(id);
        if(!el) return;
        var ns=el.nextSibling;
        var par=el.parentNode;
        par.removeChild(el); // detach temporarily
        var more;
        while(more = document.getElementById(id)){ // yes I meant = and not ==
           more.parentNode.removeChild(more);
        }
        // reattach our element
        if(ns){
          par.insertBefore(el,ns);
        }
        else{
          parent.appendChild(el);
        }
      }
      </script>
      </head>
      
      <body onload="eliminateDuplicateId('sobi2CatListSymbols')">
      ....
      </body>
      In IE6 the javascript code hides both of two tables. Am I missing something?
      Last edited by ktsixit; Apr 16, 2009, 03:49 AM.

      Comment


      • #4
        That is odd. Do you have a internet accessible test page? Or perhaps you could view source in IE6 and copy/paste to a txt file and attach that.

        Comment


        • #5
          Yes it's really odd indeed.
          This is a link to the website. Yous should browse it with firefox and ie6 to realize the problem. I have the javascript code applied.

          ...and here are some screenshots:

          before applying the script:


          after applying the javascript code:


          Any idea? Anybody??
          Last edited by ktsixit; Apr 27, 2009, 03:21 AM.

          Comment


          • #6
            Please, take a look of it.

            Comment

            Working...
            X