SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Passionate Web Developer Egyptechno's Avatar
    Join Date
    Jan 2004
    Location
    Dubai
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation [help] => problem [ IE and FireFox ]

    hello,
    I have small box contains [ description + pictures ] with two buttons :
    PHP Code:
    <span onclick="expandIt(det,pic,des,pics,'des','pics')" style="cursor:hand;"><img src="themes/Egyptechno/images/des-in.gif" alt="<%$description%>" border="0" id="des" /></span>
    <
    br/>
    <
    span style="cursor:hand;" onclick="expandIt(pic,det,pics,des,'pics','des')"><img src="themes/Egyptechno/images/pics-out.gif" alt="<%$title%>" border="0" id="pics" /></span
    and this function :
    PHP Code:
    <script type="text/javascript">
    <!--
    function 
    expandIt(i,i2,ipic,i2pic,ispic,is2pic){
      
    document.all[i.sourceIndex].style.display='';
      
    document.all[i2.sourceIndex].style.display='none';
      
    document.all[ipic.sourceIndex].setAttribute("src","themes/Egyptechno/images/"+ispic+"-in.gif");
      
    document.all[i2pic.sourceIndex].setAttribute("src","themes/Egyptechno/images/"+is2pic+"-out.gif");
    }
    -->
    </script> 
    and after I have 2 divs to show the description and picutres :
    PHP Code:
     <div id="det" style="float:right;">
    <%
    $description&>
    </
    div>
     <
    div id="pic" style="display: none; float: right;">
    <%
    $Pictures%>
    </
    div

    Ok, I know it's a bit complicated or hard to get it quickly !

    but simply, that code was made to .. :
    1- when I click on pictures :
    + the image of the description will be changed
    + the description disappears and pictures will be shown

    2- when I click on description :
    + image of pictures gone
    + pictures off, description on

    whoo seems hard to describe !

    ok, what's your problem now ?
    that code is working so well with IE but with FireFox it doesn't work at all !

    any ideas ? anyone wants more explain ?

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Call your function like this:
    expandIt('det','pic','des','pics','des','pics');

    Never use document.all blindly, change all that to:
    Code:
    function expandIt(i,i2,ipic,i2pic,ispic,is2pic){ 
      document.getElementById(i).style.display=''; 
      document.getElementById(i2).style.display='none'; 
      document.getElementById(ipic).setAttribute("src","themes/Egyptechno/images/"+ispic+"-in.gif"); 
      document.getElementById(i2pic).setAttribute("src","themes/Egyptechno/images/"+is2pic+"-out.gif"); 
    }

  3. #3
    Passionate Web Developer Egyptechno's Avatar
    Join Date
    Jan 2004
    Location
    Dubai
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks too much .. that worked

    actually, iam used to use getElementById .. but when i got [all.sourceIndex] .. I thought it's related to javascript function or something

    anyway .. thanks ^_^


Bookmarks

Posting Permissions

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