Wrox Programmer Forums
|
CSS Cascading Style Sheets All issues relating to Cascading Style Sheets (CSS).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the CSS Cascading Style Sheets section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 19th, 2007, 12:13 PM
Registered User
 
Join Date: Jan 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default IE Issues with CSS

I have created a collapsible list using CSS. The list seem to work fine on Firefox. But on IE6 , the bottom for "More" collapsible list disappears, when you expand them all and collapse them.

Could anyone help me tweak this for IE?

Thanks in advance and here is the code below


<body onLoad="makeCollapsible(document.getElementById('l eftrail'));">

<ul id="leftrail">
                                     <li>
    <div id="leftraildiv"> Products </div>
                                        [list]<li><a href="#">News 1</a></li>
                                        <li><a href="#">News 2</a></li>
                                        <li><a href="#">News 3</a></li>
                                     </ul>
                                    </li>
                                    <li>

                                    <div id="leftraildiv">More Information Etc </div>
                                                    [list]
                                        <li><a href="#">More 1</a></li>
                                        <li><a href="#">More 2</a></li>
                                                                            </ul>

                                     </li>
                                    </ul>


===== Javascript part-->
// JavaScript Document for Collapsible list



/* CLOSED_IMAGE - the image to be displayed when the sublists are closed
 * OPEN_IMAGE - the image to be displayed when the sublists are opened
 */
CLOSED_IMAGE='./images/plus2.png';
OPEN_IMAGE='./images/minus2.png';

/* makeCollapsible - makes a list have collapsible sublists
 *
 * listElement - the element representing the list to make collapsible
 */
function makeCollapsible(listElement){

  // removed list item bullets and the sapce they occupy
  listElement.style.listStyle='none';
  listElement.style.marginLeft='0';
  listElement.style.paddingLeft='0';

  // loop over all child elements of the list
  var child=listElement.firstChild;
  while (child!=null){

    // only process li elements (and not text elements)
    if (child.nodeType==1){

      // build a list of child ol and ul elements and hide them
      var list=new Array();
      var grandchild=child.firstChild;
      while (grandchild!=null){
        if (grandchild.tagName=='OL' || grandchild.tagName=='UL'){
          grandchild.style.display='none';
          list.push(grandchild);
        }
        grandchild=grandchild.nextSibling;
      }

      // add toggle buttons
      var node=document.createElement('img');
      node.setAttribute('src',CLOSED_IMAGE);
      node.setAttribute('class','collapsibleClosed');
      node.onclick=createToggleFunction(node,list);
      child.insertBefore(node,child.firstChild);

    }

    child=child.nextSibling;
  }

}

/* createToggleFunction - returns a function that toggles the sublist display
 *
 * toggleElement - the element representing the toggle gadget
 * sublistElement - an array of elements representing the sublists that should
 * be opened or closed when the toggle gadget is clicked
 */
function createToggleFunction(toggleElement,sublistElements ){

  return function(){

    // toggle status of toggle gadget
    if (toggleElement.getAttribute('class')=='collapsible Closed'){
      toggleElement.setAttribute('class','collapsibleOpe n');
      toggleElement.setAttribute('src',OPEN_IMAGE);
    }else{
      toggleElement.setAttribute('class','collapsibleClo sed');
      toggleElement.setAttribute('src',CLOSED_IMAGE);
    }

    // toggle display of sublists
    for (var i=0;i<sublistElements.length;i++){
      sublistElements[i].style.display=
          (sublistElements[i].style.display=='block')?'none':'block';
    }

  }

}






Similar Threads
Thread Thread Starter Forum Replies Last Post
connection string issues, web.config file issues kaliaparijat ASP.NET 2.0 Professional 1 June 12th, 2008 08:07 AM
CSS HELP:! CSS EXPANDIBLE BACKGROUND FOR TITLE phpuser2000 CSS Cascading Style Sheets 2 December 19th, 2007 12:36 AM
HELP: CSS COLLAPSIBLE LIST ISSUES phpuser2000 CSS Cascading Style Sheets 0 December 13th, 2007 04:22 PM
Rich's new CSS book: Beginning CSS 2nd Edition jminatel BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 0 June 15th, 2007 11:55 AM
For-each issues hiskeyd XSLT 1 February 27th, 2006 08:01 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.