SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Zealot PixelPaul's Avatar
    Join Date
    Nov 2003
    Location
    Wisconsin, USA
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Why is this not working in Firefox?

    Here is a sample page: http://pixelmagicdesign.com/test/test.html

    When you click on the icon, some text should appear. Click again to hide the text. It seems to be working on everything except Firefox on both Mac & PC. Any ideas?

  2. #2
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm amazed it's working in any browser. If you're referencing the element (e.g. exp1) then you need to use the DOM API to retrieve a reference to it from the document. E.g. document.getElementById('exp1')
    James Padolsey
    末末末末末末末末末末末末末末末末末末末
    Awesome JavaScript Zoomer (demo here)
    'Ajaxy' - Ajax integration solution (demo here)

  3. #3
    SitePoint Zealot PixelPaul's Avatar
    Join Date
    Nov 2003
    Location
    Wisconsin, USA
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the reply. Could you please be a bit more specific how I need to alter the code. I know next to nothing about Javascript.

  4. #4
    Non-Member DelvarWorld's Avatar
    Join Date
    Jul 2004
    Location
    Baloney
    Posts
    341
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My friend you absolutely must get Firebug for JavaScript debugging. It's a FireFox addon that among other things, gives you detailed JavaScript error information. You should literally do this before doing anything else with your code. RIGHT NOW.

    The problem is you are passing in do your function "doExpand" the value "exp1." Javascript doesn't know what this is. For you it's the ID of an element on the page but that means nothing when passed in as an unquoted string. The quickest method for you is probably do this, change all of your doExpand calls to pass in a STRING:
    <a href="javascript:doExpand('exp2',ar2)">

    Note the single quoets around exp2. Do that for all doExpand calls. Then inside your doExpand function you need to get the DOM element with the ID being passed in. There's a simple method to do this (which you should become famaliar with quickly). Add this line to your method:

    function doExpand(paraNum,arrowNum) {
    paraNum = document.getElementById(paraNum);
    if (paraNum.style.display=="none") {

    That will get a reference to youR DIV, which you can then check the style values of.

  5. #5
    SitePoint Zealot PixelPaul's Avatar
    Join Date
    Nov 2003
    Location
    Wisconsin, USA
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the tip with Firebug, looks very cool indeed. Unfortunately I tried your suggestions and still not working. Anybody else have any ideas?

  6. #6
    SitePoint Addict aguroyz's Avatar
    Join Date
    Jan 2009
    Location
    Konoha Fire Country
    Posts
    309
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try removing the arrownum parameter in your function and just access the ID attribute using the getElementById();
    Uniquely FILIPINO... See how talented and creative Filipinos are.
    http://www.smalltym.com
    Custom Web Designs:
    http://proweaver.com

  7. #7
    SitePoint Zealot PixelPaul's Avatar
    Join Date
    Nov 2003
    Location
    Wisconsin, USA
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Still no luck. Here is what I have now:

    <script type="text/javascript">
    function doExpand(paraNum,arrowNum) {
    paraNum = document.getElementById();
    if (paraNum.style.display=="none") {
    paraNum.style.display="";
    arrowNum.src="_images/collapse.gif";
    }
    else {
    paraNum.style.display="none";
    arrowNum.src="_images/expand.gif";
    }
    }
    </script>

  8. #8
    SitePoint Addict aguroyz's Avatar
    Join Date
    Jan 2009
    Location
    Konoha Fire Country
    Posts
    309
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    function doExpand(paraNum,arrowNum) {
        
        para = document.getElementById(paraNum);
        arrow = document.getElementById(arrowNum);
        if (para.style.display=="none") {
        para.style.display="";
        arrow.src="_images/collapse.gif";
        }
        else {
        para.style.display="none";
        arrow.src="_images/expand.gif";
        }
    }
    sample function call doExpand('exp1','ar1');

    remember to put quotes in your function calls....
    Uniquely FILIPINO... See how talented and creative Filipinos are.
    http://www.smalltym.com
    Custom Web Designs:
    http://proweaver.com

  9. #9
    SitePoint Zealot PixelPaul's Avatar
    Join Date
    Nov 2003
    Location
    Wisconsin, USA
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's it! Thanks so much.


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
  •