Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: DOM in IE6

  1. #1
    Regular Coder
    Join Date
    Jun 2007
    Location
    N. Ireland
    Posts
    351
    Thanks
    16
    Thanked 4 Times in 4 Posts

    DOM in IE6

    Hi guys been trying to do this for a client and it works in FF (both Win/Mac) and Safari but having problems in IE6/7.

    Client wants her pages to have paragraphs appearing 1 at a time with user clicking back and forward to see next/previous paragraphs.

    Fine, I thought, I will use DOM with Script.aculo.us to hide hide/show divs so I built the following:

    PHP Code:
    function showParagraph(paraID){
     var 
    aParas browseDOM();
     if(
    aParas.length 0){
     var 
    0;
     for (
    0i<aParas.lengthi++){
         
    // update paragraph displays
        
    if (i!= paraID-1){
          
    hideParagraph(i+1);
         }
     }
     new 
    Effect.BlindDown('para'+paraID);
         
    // update paragraph navigation
         
    if (paraID==1){
          
    document.getElementById('back').style.display 'none';
          
    document.getElementById('forward').style.display 'inline';
          var 
    next paraID+1;
          
    document.getElementById('fwd').setAttribute('onclick','showParagraph('+next+')');
         } else if (
    paraID==aParas.length){
          
    document.getElementById('forward').style.display 'none';
          
    document.getElementById('back').style.display 'inline';
          var 
    prev paraID-1;
          
    document.getElementById('bk').setAttribute('onclick','showParagraph('+prev+')');
         } else {
             
    document.getElementById('back').style.display 'inline';
             
    document.getElementById('forward').style.display 'inline';
             
    document.getElementById('fwd').removeAttribute('onclick');
             
    document.getElementById('bk').removeAttribute('onclick');
             var 
    next paraID+1;
             
    document.getElementById('fwd').setAttribute('onclick','showParagraph('+next+')');
             var 
    prev paraID-1;
             
    document.getElementById('bk').setAttribute('onclick','showParagraph('+prev+')');
         }
         }
    }
    function 
    hideParagraph(paraID){
     new 
    Effect.BlindUp('para'+paraID);
    }
    function 
    browseDOM() {
     
    mynode document.getElementById('col1');
     
    thingylist mynode.childNodes;
     var 
    aParas = new Array();
     var 
    counter 0;
     for(var 
    i=0;i<thingylist.length;i++){
         if (
    thingylist[i].nodeType == && thingylist[i].id.substring(0,1)== 'p'){
          
    aParas[counter] = thingylist[i].id.substring(4);
          
    counter++;
         }
     }
     return 
    aParas;

    Each Paragraph is wrapped around a div with ID 'para1','para2' etc.

    Dev site is at aegean.newcreation.com if you would like to check.

    Any help appreciated.

    D.

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,042
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Change the onclicks to this format.
    Code:
    document.getElementById('fwd').onclick = new Function('showParagraph('+next+')');

  • #3
    Regular Coder
    Join Date
    Jun 2007
    Location
    N. Ireland
    Posts
    351
    Thanks
    16
    Thanked 4 Times in 4 Posts
    Glenn,

    Thanks for the quick response. Will this work in both IE/FF?
    Do I need to remove the attribute before I recreate it? If so, Is the given code acceptable in IE?

    D.

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,042
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Remove setAttribute('onclick', '...')
    That doesn't work in IE. The code I posted works for both IE and Firefox.

  • #5
    Regular Coder
    Join Date
    Jun 2007
    Location
    N. Ireland
    Posts
    351
    Thanks
    16
    Thanked 4 Times in 4 Posts
    Thanks I will try that in the morning.

    D.

  • #6
    Regular Coder
    Join Date
    Jun 2007
    Location
    N. Ireland
    Posts
    351
    Thanks
    16
    Thanked 4 Times in 4 Posts
    Glenn,

    Thanks for the code snippet. Worked a treat.
    Site is now live - www.aegeandreamproperty.com

    D.


  •  

    Posting Permissions

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