473,387 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Get Div Id where mouse was clicked

91
I'm trying to get the Div ID that the mouse was clicked in so that if it was not clicked in id ('divContext') then it will hide ('divContext'). What I have right now works perfect in FF but not in IE. The div will not go away even when a link is clicked.

Expand|Select|Wrap|Line Numbers
  1. //see if the focus has been taken off of the div and if so hide it.
  2. function on_down(e)
  3. {
  4.     //alert('test');
  5.     if (e == null) { e = window.event; }
  6.     var evt = e.target || e.srcElement;
  7.     //alert(evt.id);
  8.     if (evt.id != 'divContext' && evt.id != 'aView' && evt.id != 'aComplete')
  9.     {
  10.         if (document.getElementById('divContext').style.display != 'none')
  11.         {
  12.             document.getElementById('divContext').style.display = 'none';
  13.         }
  14.     }
  15. }
  16. // See if a link in the div was clicked.
  17. function on_up(e)
  18. {
  19.     if (e == null) { e = window.event; }
  20.     var evt = e.target;
  21.     //alert(evt.id);
  22.     if (evt.id == 'aView' || evt.id == 'aComplete')
  23.     {
  24.         if (document.getElementById('divContext').style.display != 'none')
  25.         {
  26.             document.getElementById('divContext').style.display = 'none';
  27.         }
  28.     }
  29. }
  30.  
  31. onload=function()
  32. {
  33.     onmousedown = on_down;
  34.     onblur = on_down;
  35.     onmouseup = on_up;
  36. }
  37.  
Anyone know why this will not work in IE?
May 2 '08 #1
1 2472
acoder
16,027 Expert Mod 8TB
For the on_up function, you forgot the srcElement part (which you have in the on_down) function.
May 3 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Andreas Müller | last post by:
Hi all, I need to wait for the user to click the mouse: // some code before WaitForMouseClick();// Wait until the user clicks the mouse // go on doing something Under Win32 using C++, you...
1
by: DotNetMania | last post by:
panel has not Key press event... that's why.. if i have to figure invoking any event out when panel clicked it is so difficult...what button is clicked .... button of Mouse like .. Left,...
4
by: Raj Chudasama | last post by:
I have a controls similiar to the windows calculator. (Please press some buttons on your calculator to see what i am talking about) So when u hover over a button it will change the state (it...
3
by: jcrouse | last post by:
I have created a form designer type application (with a lot of you peoples helpJ). It has label controls that are draggable at runtime. The user is also allowed to change some properties such as...
0
by: StriderBob | last post by:
In a simple two form project, use a button on each form to Show() the other form and Hide() the current form. Add MouseEnter and MouseLeave events to both buttons so they change the image on each...
0
by: mmcd79 | last post by:
I'm wondering if anyone else is having this issue. It's driving me batty. It seems my mouse wants to "double click" on items when I'm just doing a single click. I thought it was the mouse so I...
10
by: sagar | last post by:
hi everyone, i m having a problem with mouse events. any help related is apreciated. i m having a form in which i m having 2 buttons. and i m moving(draging) these buttons on run time using...
2
by: John | last post by:
Ok, something that I thought would be easy is giving me fits. Using .NET 2.0 and C# I've added a Trackbar to a form. Set some values: trackVolume.Maximum = 100; trackVolume.Minimum = 0;...
5
by: Adeel | last post by:
Hi group! I'm trying to learn C# on my own... I'd appreciate it very much if someone can help me out here. I have a basic form without any controls on it... I want to catch mouse clicks (both...
6
by: marss | last post by:
Hi, How can I define in Firefox whether the left mouse button is pressed when I move mouse over a html element? The documentation says that "e.button == 0 for standard 'click', usually left...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.