www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > JavaScript

    JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...)

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 02-24-2007, 04:13 AM
    livinus livinus is offline
    Registered User
     
    Join Date: Feb 2007
    Posts: 3
    Question Image maps - onmouseon, onmouseout?

    Hey there,

    I want to create this effect: I make an Image map with hotspots (I know how to do this), and when the user goes over one of those hotspots, in another cell a discription should appear (I don't know how to do this). I don't know much about JavaScript, but I think that's the language I should use to get this effect? Can somebody please help?


    I already had a go on this, which resulted in the code below. Maybe you people can find where I got wrong, as the effect isn't working with this. Or should I just try a totally different thing?



    Quote:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    <script type="text/javascript">

    showdiscription(id){
    document.getElementById("discription" + id).style.display = "block";
    };

    hidediscription(id){
    document.getElementById("discription" + id).style.display = "none";
    };

    </script>
    </head>

    <body>
    <table width="750" height="300" border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td width="600" valign="top"><img src="Images/Groepsfoto/Groepsfoto.JPG" width="600" height="284" border="0" usemap="#Map" /></td>
    <td><table width="150" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td height="196">&nbsp;</td>
    </tr>
    <tr>
    <td height="74">
    <div id="discription1" style="display: none;">
    Dit is beschrijving nummer 1.
    </div>
    <div id="discription2" style="display: none;">
    Dit is beschrijving nummer 2.
    </div>
    <div id="discription3" style="display: none;">
    Dit is beschrijving nummer 3.
    </div>
    </td>
    </tr>
    </table></td>
    </tr>
    </table>

    <map name="Map" id="Map">
    <area shape="circle" coords="301,37,19" href="#" onmouseover="showdiscription(1);" onmouseout="hidediscription(1);" />
    <area shape="circle" coords="337,44,18" href="#" onmouseover="showdiscription(2);" onmouseout="hidediscription(2);" />
    <area shape="circle" coords="366,71,15" href="#" onmouseover="showdiscription(3);" onmouseout="hidediscription(3);" />
    </map>

    </body>
    </html>

    Any help would be greatly appreciated,
    livinus
    Reply With Quote
      #2  
    Old 02-24-2007, 05:09 AM
    spiresgate spiresgate is offline
    Registered User
     
    Join Date: Jan 2007
    Posts: 183
    You look as if you are trying to do something I have had some success with on my website:

    http://myweb.tiscali.co.uk/spiresgat...Web/2alpha.htm

    If you put the cursor over the nose of a student then a larger version appears at top right and a contemporary version may appear below it. In addition the student's name will be seen as a yellow sticker. If you click on the face when the sticker appears the you will get further information either as an alert or as a full page in a new window.

    This is done using hot spots as you have set it up. You could probably use my code to replace the lower school badge with a block of descriptive text.

    I must confess that I arrived at my solution by blundering around a bit and it may not be very elegant but perhaps it will give you some ideas. I might even use your code to clean mine up in places.
    Reply With Quote
      #3  
    Old 02-24-2007, 06:21 AM
    livinus livinus is offline
    Registered User
     
    Join Date: Feb 2007
    Posts: 3
    It's something like this I'm looking for, but instead of the zoomed-in version on the right, I'd like to have the name there. So no alternative text that brings the name under the cursor when you stay for some time on somebody's head. Your code indeed looks quite difficult to me. And by the way, the code I posted really isn't working properly, so I guess copying it for your site isn't quite a good idea ...

    Can anybody solve my problem
    Reply With Quote
      #4  
    Old 02-24-2007, 06:42 AM
    Orc Scorcher Orc Scorcher is offline
    S.P.Q.R.
     
    Join Date: Mar 2005
    Posts: 767
    Pay attention to the browsers error messages, the 'function' keywords are missing in your code. Btw, you don't need the onmouseout for each area, you can use the map's onmouseout handler:
    Code:
    function showdiscription(id){
       var descriptionStyle = document.getElementById("discription" + id).style;
       descriptionStyle.display = "block";
       document.getElementById("Map").onmouseout = function () {
          descriptionStyle.display = "none";
          this.onmouseout = null;
       }
    };
    __________________
    Stop thinking, start drinking.
    Reply With Quote
      #5  
    Old 02-24-2007, 08:10 AM
    livinus livinus is offline
    Registered User
     
    Join Date: Feb 2007
    Posts: 3
    resolved

    Thanks, this was of great help. I changed the old code with yours and now it's working fine!

    Leaving out the onmouseout for each area worked too! Thanks a lot!
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 12:57 PM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.