473,327 Members | 2,112 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,327 software developers and data experts.

detect mouse click event

Hi,
When I click on a link it shows a div above all other elements of my
page (a kind of popup). I would like to close it(hide the div again)
when the user clicks anywhere on the screen. How can i do that? The
'event listener' should only be activated if the div is visible.

thanks

Jul 7 '06 #1
3 8668
wrote on 07 jul 2006 in comp.lang.javascript:
When I click on a link it shows a div above all other elements of my
page (a kind of popup). I would like to close it(hide the div again)
when the user clicks anywhere on the screen. How can i do that? The
'event listener' should only be activated if the div is visible.
<body onclick='if(thatDivDisplayBlock)thatDivDisplayNone ()'>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 7 '06 #2
Thanks.
I can't access the body from my page as it is in a master page (i'm
doing asp.net). However I have a javascript function bodyLoad() which
is called at body load and in which I can do stuff. How can I assigne
the onclick event in this function ?
Evertjan. wrote:
wrote on 07 jul 2006 in comp.lang.javascript:
When I click on a link it shows a div above all other elements of my
page (a kind of popup). I would like to close it(hide the div again)
when the user clicks anywhere on the screen. How can i do that? The
'event listener' should only be activated if the div is visible.

<body onclick='if(thatDivDisplayBlock)thatDivDisplayNone ()'>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 7 '06 #3
wrote on 07 jul 2006 in comp.lang.javascript:
Evertjan. wrote:
>wrote on 07 jul 2006 in comp.lang.javascript:
When I click on a link it shows a div above all other elements of my
page (a kind of popup). I would like to close it(hide the div again)
when the user clicks anywhere on the screen. How can i do that? The
'event listener' should only be activated if the div is visible.

<body onclick='if(thatDivDisplayBlock)thatDivDisplayNone ()'>
[please skip the signature in replies,
or have a decent newsreader do that automagically]
>--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
[please do not toppost on usenet, corrected]
I can't access the body from my page as it is in a master page (i'm
doing asp.net). However I have a javascript function bodyLoad() which
is called at body load and in which I can do stuff. How can I assigne
the onclick event in this function ?
I would have no idea about "bodyLoad()": if this is asp.net, better ask
an asp.net group.

What is a master-page? Are you using iframes? Or is the <bodyset in a
include?

what about:

body.onload = myfunc; // Use no () !

function myfunc() {
if (thatDiv.display != 'none') // this line could be skipped ;-)
thatDiv.display = 'none';
};

not tested

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 7 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: punkin | last post by:
I am trying to catch mouse position on the entire screen by dynamically generating mouse click event at every 100 ms. My code only works for IEs but not any Netscape or Gecko-based browsers. The...
4
by: Simon Pedersen | last post by:
Hi, I have a site here: http://www.atom.no/christiane/default.asp?menu=4&view=app_resource&app_id=20&app=20&response=1&body=0&RESOURCE_ID=2 which uses divs to create a outlook like calendar...
3
by: mitsura | last post by:
Hi, I have included a small listing. The test program opens a panel and show a bitmap. What I want is to when the mouse is over the bitmap panel, I want to trap the left mouse click. The...
4
by: Harry J. Smith | last post by:
How can you detect a mouse double click on a text box? I tried the following but it does not work. private void richTextOut_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) //...
1
by: Diogo Alves - Software Developer | last post by:
Hi Can Someone tell me how to detect a click on the windows form border? I really need this... and I can't find a solution :( Thanks in Advance
5
by: Nick | last post by:
Hey guys, I have 2 events on a windows forms datagrid, the mouse move as well as the double click events. What's happening is that when I double click on a row in the grid, the mouse move event...
2
by: scott_gui | last post by:
I am creating a Windows application: The mouse event <Double-Button-1> has a conflict when the <Button-1> event also has a binding. Double clicks will first perform the single click action. This...
3
by: Randy Harris | last post by:
With a multiple column listbox, I'd like to be able to change the sort by allowing the user to click on a column. Is there a practical way detect in which column the user clicked? I know this...
3
by: akowald | last post by:
There's another topic like this but the code posted is in VB.NET. Well I need some help detecting mouse clicks outside the form. An event handler would be great but I can work with anything. ...
1
by: john ciriello | last post by:
Hi, is there an easy way to detect when the mouse pointer enters a disabled button? For example I have a button I can see but it is greyed out. When the mouse moves over it I would like to be able...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.