Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 7 of 7
  1. #1
    Senior Member tonyf12's Avatar
    Join Date
    Mar 2007
    Posts
    132
    Member #
    14998
    I have blocks on my page that can be maximised/minimised and an image that users click on to switch. It changes the image correctly but the alt attribute is stuck on minimise (the starting value)

    Here is the code:

    Code:
    function changeSize(section) {
        var sectionIconName = section + "-size"; // All minimise/maximise buttons are named same as the section + -size
        var sectionIcon = document.getElementById(sectionIconName); // Get the icon
        var sectionStyle = document.getElementById(section).style; // Styles for the section
        
        if(sectionStyle.display != "none") { // Section is displayed
            sectionIcon.src = baseurl + "images/maxi.png"; // Switch to maximise icon
            sectionIcon.alt = "maximise"; // Change alt text in case image doesn't display    
            sectionStyle.display = "none"; // Hide section
        }
        else { // Section is hidden
            sectionIcon.src = baseurl + "images/mini.png"; // switch to minimise icon
            sectionIcon.alt = "minimise"; // Change alt text in case image doesn't display
            sectionStyle.display = "block"; // Reveal section
        }
        
    }

  2.  

  3. #2
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Looks like it should work, especially if the display gets updated appropriately. What browser(s) is this not working on?

  4. #3
    Senior Member tonyf12's Avatar
    Join Date
    Mar 2007
    Posts
    132
    Member #
    14998
    Firefox and Opera. I couldn't find the disable images option to test it in IE or Safari.

  5. #4
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Ok, any chance we could get a test page?

  6. #5
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Try it through the DOM:
    Code:
    sectionIcon.setAttribute("alt", "minimize");
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  7. #6
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Though watch for using setAttribute in Firefox. Strange things can happen, because this is not synonymous to changing the `alt' property of the object.

  8. #7
    Senior Member tonyf12's Avatar
    Join Date
    Mar 2007
    Posts
    132
    Member #
    14998
    Quote Originally Posted by filburt1
    Try it through the DOM:
    Code:
    sectionIcon.setAttribute("alt", "minimize");
    That worked. Thanks


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 01:03 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com