Current location: Hot Scripts Forums » General Web Coding » JavaScript » onClick div popup problem?


onClick div popup problem?

Reply
  #1 (permalink)  
Old 12-30-07, 09:27 AM
adz_619 adz_619 is offline
New Member
 
Join Date: Dec 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
onClick div popup problem?

I am in the process of creating a desktop-style website. I have an image map which has hotspots for all the different icons on my website. When an icon is clicked a div should popup.

Below is my div code from the css:

css Code:
  1. #about {
  2. border: 1px solid #ccc;
  3. height: 120px;
  4. width: 400px;
  5. overflow: auto;
  6. margin: 1em 0;
  7. }



Here is my image map code:

HTML Code:
<img src="map/map.png" alt="Desktop Image map" border="0" usemap="#desktop" />
<map name="desktop" id="desktop"><area shape="rect" coords="20,78,87,152" href="#" alt="Home Icon" />
<area shape="rect" coords="123,77,177,153" href="#" alt="About Icons" />
<area shape="rect" coords="220,81,271,157" href="#">onclick="" target="_self" alt="Work Icon" />
</area></map>


What do I need to put in the onClick section for the about div to pop up on top of the image map, not above or below!

Thanks in advance
Adam

Last edited by mab; 12-30-07 at 09:44 AM. Reason: Please post code in code tags. No red bold please.
Reply With Quote
  #2 (permalink)  
Old 12-30-07, 10:20 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
you need to get the current mouse position, either by using the passed on event object (event.clientX and event.clientY), or by tracking the mouse position when moving across the html page (onmousemove). When you found the position, you have to set the "top" and "left" property of the div's style
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
  #3 (permalink)  
Old 12-30-07, 10:32 AM
adz_619 adz_619 is offline
New Member
 
Join Date: Dec 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
I understand what you are saying, but how would I track the mouse position using code. I know the coords for the icons on the page. How would I track and set the "top" and "left" property in code???
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
popup problem mahmoud82 PHP 3 02-04-07 11:21 AM
popup Problem dharprog JavaScript 4 11-01-06 07:12 AM
Problem with popup window in script Crizz JavaScript 5 04-27-06 06:45 PM
Newbie problem with OnClick newwindow and ASP ianric JavaScript 1 11-30-05 05:32 AM
CSS Div problem themanmathias CSS 1 09-29-05 08:05 PM


All times are GMT -5. The time now is 11:33 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.