Results 1 to 2 of 2

Thread: [RESOLVED] for-loop in ie counts one more

  1. #1
    Join Date
    Aug 2007
    Germany, NRW

    resolved [RESOLVED] for-loop in ie counts one more


    i have a cross-browser compability issue between m$ ie and the rest of the World... involving a counting Problem with a for-loop in ie. In Firefox it doing 8 rounds, IE it doing 9. Is there any incompatibility with arrays and for-loops that i am until know not aware of?

    The whole story:
    I use greybox to show pdfs and additional html content in an overlay. The nice thing with greybox is, if you are in overlay mode you can browse the rest of the gallery items from there. You don´t need to close the overlay to select a new item.

    I tried to fully automate the process of attaching eventhandlers to my thumbnails and succeded short for one problem with ie. You register the items that should be shown in the overlay gallery by putting them in an array like this:

    PORTFOLIO.page_set_portfolio_gallery = [
      {'caption': 'EXAMPLE1', 'url': 'http://www.example.com/index.php?id=21/'},
      {'caption': 'EXAMPLE2', 'url': 'http://www.example.com/index.php?id=20/'},
      {'caption': 'EXAMPLE3', 'url': 'http://www.example.com/index.php?id=19/'}
    So 3 Items!

    Next i run through my thumbnails(items) and attach an click-eventlistener to every one of them to do some setup and finally trigger greybox display. This looks like this:

    PORTFOLIO.greybox_projects_gallery_setup = function() {
      /*get an array of referneces to every item of the gallery */
      PORTFOLIO.li_in_gallery = PORTFOLIO.gallery_elem.getElementsByTagName('li');
      /* for all Items: */
      for(var i=0; i < PORTFOLIO.li_in_gallery.length; i++) {
        /* get an array of all link with an item*/
        PORTFOLIO.links_per_li = PORTFOLIO.li_in_gallery[i].getElementsByTagName('a');
        /* for all links in an item:*/
        for(var j= 0; j < PORTFOLIO.links_per_li.length; j++) {
          /* deaktivate no-script backup link */
          /* force cursor: pointer as it falls back to default without the href attribute */
          PORTFOLIO.links_per_li[j].style.cursor = 'pointer';
          /* save an identifier, so greybox knows wich item to show first */
          DOM.appendAttribute(PORTFOLIO.links_per_li[j], 'greybox_item_identifier', i+1);
          /* add Eventhandler on click to every link in an item*/
          EVENT.addEventWithElem(PORTFOLIO.links_per_li[j], 'click', function(e) {
            /* unifing workaround for Events */
            if(!e) var e = window.event;
            /* Load from item attribute the page to show first for greybox (doing workaround for ms js)*/
            if(e.currentTarget === undefined) { var targ = e.srcElement.parentElement; }
              else { var targ = e.currentTarget; }
            PORTFOLIO.current_greybox_item_identifier = targ.getAttribute('greybox_item_identifier');
            /* call Greybox with specific page_set array*/
            GB_showFullScreenSet(PORTFOLIO.page_set_portfolio_gallery, PORTFOLIO.current_greybox_item_identifier);
    As you can see i grab all items(tn) of the page and store them in PORTFOLIO.li_in_gallery. The length of the array in firefox and ie is the same.

    The Problem is the for-loop(with counter i) that runs over PORTFOLIO.li_in_gallery. In IE it does an additional round.

    So in firefox and the rest of the world i get:
    with 3 items in my array(PORTFOLIO.li_in_gallery) a greybox overlay gallery with 3 items.

    but in Internet Explorer i get 4, the additional one is empty and throws an js error(its complaining about the lack of input out of PORTFOLIO.page_set_portfolio_gallery) as soon it is reached.

    So what do you think?



    PS :

    here`s the Html
    <h2 class="invisible">Portfolio Gallerie</h2>
                <ul id="projects_gallery">
                  <li category_item="webseite">
                      <dt><a href="index.php?id=21"><img src="typo3temp/GB/a57e86f273.png"  /></a></dt>
                      <dd class="invisible"><a href="index.php?id=21">EXAMPLE</a></dd>
                  <li category_item="alle_kategorien">
                      <dt><a href="index.php?id=20"><img src="typo3temp/GB/30d76852fc.png"  /></a></dt>
                      <dd class="invisible"><a href="index.php?id=20">EXAMPLE</a></dd>
    Last edited by jens1701; 06-14-2009 at 10:22 AM.

  2. #2
    Join Date
    Aug 2007
    Germany, NRW


    my bad,

    oversaw an bracket in my data array.

    Problem solved

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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