Solved

Display a PopUp Image For Each Area In An Image Map

Posted on 2006-11-28
12
250 Views
Last Modified: 2008-03-05
I have an image map on a html page. For each area I have marked as  a hotspot, I would like to have an image appear as a mouseover event. If the onclick event is triggered the link specified must be visited.

Can any Javascript Expert help.

Thank You
phpamble
0
Comment
Question by:phpamble
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
12 Comments
 
LVL 1

Author Comment

by:phpamble
ID: 18028108
I do not want to use the rollover image feature.
0
 
LVL 6

Expert Comment

by:system_down
ID: 18029374

Try putting an onmouseover event....

look at this: http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20608160.html?query=tooltip&topics=87

seems to be usefull

Let me know
S_D

0
 
LVL 1

Author Comment

by:phpamble
ID: 18029740
Thanks for the quick response

The area parameter that I currently have in one of the areas of the image map is in the form:

<area shape="poly" coords="170,209,198,187,231,188,261,189,270,196,208,247,171,252,150,238,152,224" href="" target="_self" alt="Eastern Cape" />

So I assume that I will include a javascript function call like onclick="showPic(this);" at the end after alt="Eastern Cape"

Could you give me any assistance on how to write showPic(this)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 23

Expert Comment

by:rama_krishna580
ID: 18031263
Hi,

look at the documentation it might help you..
http://www.htmltutorials.ca/lesson20.htm

R.K
0
 
LVL 6

Expert Comment

by:system_down
ID: 18031463
something like:

            function showPic(el, img){
              
            var oDiv = document.getElementById('image');
            if(oDiv == null){
                  oDiv  = document.createElement('div');
                oDiv.id = 'image';
                  oDiv.style.border = '1px solid #000';
                  oDiv.style.background = '#DDD';
                  oDiv.style.position = 'absolute';
                  oDiv.style.padding = '5px';
                  oDiv.style.width = '100px';
            }
            
            oDiv.style.zIndex = '10000';
            oDiv.innerHTML = '<img src='+img+'/> ';
            oDiv.style.visibility = 'visible';

            if (document.all)
              oDiv.style.left=window.event.clientX, oDiv.style.top=window.event.clientY;
                else if (document.layers)
                    oDiv.style.left=e.pageX, oDiv.style.top=e.pageY;
                        
            
            document.body.appendChild(oDiv);
            
            
            }
            
      

      function hidePic() {
            var oDiv = document.getElementById('image');
            oDiv.style.visibility = 'hidden';
      }
            


<div onmouseover="showPic(this, 'test.jpg')" onmouseout="hidePic()">test</div>


let me know
S_D
0
 
LVL 1

Author Comment

by:phpamble
ID: 18034876
Thanks to everybody.

system_down  I have copied your code and have tested it. It shows a popup box but only a placeholder for the image.

0
 
LVL 6

Expert Comment

by:system_down
ID: 18035091

Maybe I didn't really understand what you need...
tell me more pls
0
 
LVL 1

Author Comment

by:phpamble
ID: 18035209
I have an imagemap that is broken into areas. I.E.

<area shape="poly" coords="170,209,198,187,231,188,261,189,270,196,208,247,171,252,150,238,152,224" href="" target="_self" alt="Eastern Cape" />

One then for each area.

What I would like is for an image to appear on the onmouseover event whent the cursor passes over this area.

Is this possible?
0
 
LVL 6

Accepted Solution

by:
system_down earned 500 total points
ID: 18035408

<MAP Name="mymap">
<AREA Shape="circle" Coords="70,84,51"
         Href="http://www.december.com">
<AREA Shape="rect" Coords="25,180,125,280"
         Href="http://www.december.com/html/">
<AREA Shape="poly" Coords="153,106,186,225,340,193,315,81,304,167"
         Href="http://www.december.com/works/tour.html">
<AREA Shape="rect" Coords="422,17,480,277" Nohref onmouseover="alert('rect')">
<AREA Shape="circle" Coords="499,299,100"
         Href="http://www.cnn.com/">
<AREA Shape="default" Coords="0,0,195,111"
         Href="http://www.december.com/john/">
</MAP>

<IMG Src="test.gif" Width="500" Height="300"
        Alt="Image Map" Usemap="#mymap" Ismap>
      

Ok, yes it is possible!!! you can put an onmouseover event in the shape you need...
then call the showpic();

Let me know
S_D
0
 
LVL 1

Author Comment

by:phpamble
ID: 18035591
If I put the function call in the shape, Nohref onmouseover="alert('rect')", a new window is opened

But the following does not generate any popup, namely

Nohref onmouseover="showPic(this, 'pic.jpg')"

Thanks for the help thus far!

0
 
LVL 6

Expert Comment

by:system_down
ID: 18035622

your welcome.

S_D
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month11 days, 11 hours left to enroll

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question